mirror of
https://github.com/sergeyyarkov/todo-mobx-app.git
synced 2026-10-11 10:29:13 +03:00
feat: readme & input clear after add todo
This commit is contained in:
parent
0382fbf205
commit
47ab776816
62
README.md
62
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`
|
||||

|
||||
|
||||
Runs the app in the development mode.<br /> Open
|
||||
[http://localhost:3000](http://localhost:3000) to view it in the browser.
|
||||
#### 🛠 Tools:
|
||||
|
||||
The page will reload if you make edits.<br /> You will also see any lint errors
|
||||
in the console.
|
||||
|
||||
### `yarn test`
|
||||
|
||||
Launches the test runner in the interactive watch mode.<br /> 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.<br /> 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.<br /> 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
|
||||
|
||||
@ -11,7 +11,7 @@ import TodoList from './components/TodoList';
|
||||
export const App = () => {
|
||||
return (
|
||||
<ChakraProvider theme={theme}>
|
||||
<Box maxW='800px' mt='5' mr='auto' ml='auto'>
|
||||
<Box maxW='800px' mt='5' mr='auto' ml='auto' p='10'>
|
||||
<TodoHeader />
|
||||
<TodoInput />
|
||||
<TodoList />
|
||||
|
||||
@ -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 = () => {
|
||||
<form
|
||||
onSubmit={(e: React.FormEvent<HTMLFormElement>) => {
|
||||
e.preventDefault();
|
||||
|
||||
todoStore.createTodo({
|
||||
id: todoStore.todos.length + 1,
|
||||
title: formState.title,
|
||||
createdAt: new Date(),
|
||||
updatedAt: new Date(),
|
||||
});
|
||||
|
||||
setFormState({ title: '' });
|
||||
}}>
|
||||
<FormControl>
|
||||
<Flex>
|
||||
@ -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
|
||||
/>
|
||||
<Button type='submit' size='md'>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user