From 47ab7768167127feead0103944e98b81849c3e88 Mon Sep 17 00:00:00 2001 From: Sergey Yarkov Date: Wed, 18 Aug 2021 12:44:57 +0300 Subject: [PATCH] feat: readme & input clear after add todo --- README.md | 62 +++++------------------------------- src/App.tsx | 2 +- src/components/TodoInput.tsx | 7 ++-- 3 files changed, 14 insertions(+), 57 deletions(-) diff --git a/README.md b/README.md index 9dcf25b..2a882de 100644 --- a/README.md +++ b/README.md @@ -1,59 +1,13 @@ -This project was bootstrapped with -[Create React App](https://github.com/facebook/create-react-app). +# React todo app -## Available Scripts +#### Simple todo application using mobx state manager -In the project directory, you can run: +#### đź“· Screenshot: -### `yarn start` +![React todo app](https://i.imgur.com/t626C4i.png) -Runs the app in the development mode.
Open -[http://localhost:3000](http://localhost:3000) to view it in the browser. +#### đź›  Tools: -The page will reload if you make edits.
You will also see any lint errors -in the console. - -### `yarn test` - -Launches the test runner in the interactive watch mode.
See the section -about -[running tests](https://facebook.github.io/create-react-app/docs/running-tests) -for more information. - -### `yarn build` - -Builds the app for production to the `build` folder.
It correctly bundles -React in production mode and optimizes the build for the best performance. - -The build is minified and the filenames include the hashes.
Your app is -ready to be deployed! - -See the section about -[deployment](https://facebook.github.io/create-react-app/docs/deployment) for -more information. - -### `yarn eject` - -**Note: this is a one-way operation. Once you `eject`, you can’t go back!** - -If you aren’t satisfied with the build tool and configuration choices, you can -`eject` at any time. This command will remove the single build dependency from -your project. - -Instead, it will copy all the configuration files and the transitive -dependencies (webpack, Babel, ESLint, etc) right into your project so you have -full control over them. All of the commands except `eject` will still work, but -they will point to the copied scripts so you can tweak them. At this point -you’re on your own. - -You don’t have to ever use `eject`. The curated feature set is suitable for -small and middle deployments, and you shouldn’t feel obligated to use this -feature. However we understand that this tool wouldn’t be useful if you couldn’t -customize it when you are ready for it. - -## Learn More - -You can learn more in the -[Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started). - -To learn React, check out the [React documentation](https://reactjs.org/). +- React.js +- MobX +- ChakraUI diff --git a/src/App.tsx b/src/App.tsx index 2466d5f..70d8575 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -11,7 +11,7 @@ import TodoList from './components/TodoList'; export const App = () => { return ( - + diff --git a/src/components/TodoInput.tsx b/src/components/TodoInput.tsx index 41244d7..1d5118d 100644 --- a/src/components/TodoInput.tsx +++ b/src/components/TodoInput.tsx @@ -3,7 +3,7 @@ import React from 'react'; import { useStores } from '../hooks/useStores'; const TodoInput: React.FC = () => { - const [formState, setformState] = React.useState<{ title: string }>({ + const [formState, setFormState] = React.useState<{ title: string }>({ title: '', }); const { todoStore } = useStores(); @@ -13,12 +13,15 @@ const TodoInput: React.FC = () => {
) => { e.preventDefault(); + todoStore.createTodo({ id: todoStore.todos.length + 1, title: formState.title, createdAt: new Date(), updatedAt: new Date(), }); + + setFormState({ title: '' }); }}> @@ -27,7 +30,7 @@ const TodoInput: React.FC = () => { size='md' mr='2' value={formState.title} - onChange={(e) => setformState({ title: e.target.value })} + onChange={(e) => setFormState({ title: e.target.value })} isRequired />