introduce containers and core folders

This commit is contained in:
Ruidy 2020-10-22 15:24:00 +02:00
parent 0aca319c24
commit c4afcc18c8
7 changed files with 60 additions and 16 deletions

View file

@ -1,23 +1,24 @@
module.exports = {
parser: "@typescript-eslint/parser", // Specifies the ESLint parser
parser: '@typescript-eslint/parser', // Specifies the ESLint parser
parserOptions: {
ecmaVersion: 2020, // Allows for the parsing of modern ECMAScript features
sourceType: "module", // Allows for the use of imports
sourceType: 'module', // Allows for the use of imports
ecmaFeatures: {
jsx: true // Allows for the parsing of JSX
}
},
settings: {
react: {
version: "detect" // Tells eslint-plugin-react to automatically detect the version of React to use
version: 'detect' // Tells eslint-plugin-react to automatically detect the version of React to use
}
},
extends: [
"plugin:react/recommended", // Uses the recommended rules from @eslint-plugin-react
"plugin:@typescript-eslint/recommended" // Uses the recommended rules from @typescript-eslint/eslint-plugin
'plugin:react/recommended', // Uses the recommended rules from @eslint-plugin-react
'plugin:@typescript-eslint/recommended' // Uses the recommended rules from @typescript-eslint/eslint-plugin
],
rules: {
'react/prop-types': 0
// Place to specify ESLint rules. Can be used to overwrite rules specified from the extended configs
// e.g. "@typescript-eslint/explicit-function-return-type": "off",
},
};
}
};

View file

@ -1,8 +1,8 @@
import React, { FC } from 'react';
import { Route, Switch } from 'react-router-dom';
import { Home } from './components/Home';
import { About } from './components/About';
import { Home } from './containers/Home';
const Router: FC = () => (
<Switch>

View file

@ -1,8 +0,0 @@
import React, { FC } from 'react';
export const Home: FC = () => (
<div>
<h1>Hello</h1>
<p>Hi there!</p>
</div>
);

View file

@ -0,0 +1,20 @@
import React, { FC } from 'react';
import Todo from '../core/models/todo';
interface Props {
todos: Todo[];
}
export const TodoList: FC<Props> = ({ todos }) => (
<div>
<h1>Your tasks</h1>
<p>Hi there!</p>
<ul>
{todos.map((todo) => (
<li key={todo.id}>
{todo.title}, status: {todo.isDone ? 'Done' : 'In Progress'}
</li>
))}
</ul>
</div>
);

9
src/containers/Home.tsx Normal file
View file

@ -0,0 +1,9 @@
import React, { FC } from 'react';
import { listTodos } from '../core/services/todo';
import { TodoList } from '../components/TodoList';
export const Home: FC = () => {
const todos = listTodos();
return <TodoList todos={todos} />;
};

5
src/core/models/todo.ts Normal file
View file

@ -0,0 +1,5 @@
export default interface Todo {
id: string;
title: string;
isDone: boolean;
}

17
src/core/services/todo.ts Normal file
View file

@ -0,0 +1,17 @@
import Todo from '../models/todo';
export const listTodos = (): Todo[] => {
console.log('create list');
return [
{
id: '1',
title: 'test',
isDone: false
},
{
id: '2',
title: 'second',
isDone: true
}
];
};