-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #27 from szhsin/docs/useSelector
Docs: useSelector
- Loading branch information
Showing
10 changed files
with
145 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { useSnapshot } from 'reactish-state'; | ||
import { todoListState, visibleTodoList } from './store'; | ||
import styles from './styles.module.css'; | ||
|
||
const VisibleTodoList = () => { | ||
const todos = useSnapshot(visibleTodoList); | ||
const { toggleItem, deleteItem } = todoListState.actions; | ||
|
||
return ( | ||
<ul className={styles.todos}> | ||
{todos.map(({ id, text, isCompleted }) => ( | ||
<li key={id} className={styles.todo}> | ||
<label className={styles.todoLabel}> | ||
<input type="checkbox" checked={isCompleted} onChange={() => toggleItem(id)} /> | ||
<span className={isCompleted ? styles.completed : ''}>{text}</span> | ||
</label> | ||
<button className={styles.delete} onClick={() => deleteItem(id)}> | ||
Delete | ||
</button> | ||
</li> | ||
))} | ||
</ul> | ||
); | ||
}; | ||
|
||
export { VisibleTodoList }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,25 @@ | ||
import { useEffect } from 'react'; | ||
import { hydrateStore } from './store'; | ||
import { AddTodo } from './AddTodo'; | ||
import { TodoList } from './TodoList'; | ||
import { VisibleTodoList } from './VisibleTodoList'; | ||
import { Filters } from './Filters'; | ||
import { Stats } from './Stats'; | ||
import { TodoList } from './TodoList'; | ||
import styles from './styles.module.css'; | ||
|
||
export default function Todo() { | ||
export default function App() { | ||
useEffect(() => { | ||
hydrateStore(); | ||
}, []); | ||
|
||
return ( | ||
<div className={styles.app}> | ||
<AddTodo /> | ||
<TodoList /> | ||
<VisibleTodoList /> | ||
<Filters /> | ||
<Stats /> | ||
<TodoList filter="ACTIVE" /> | ||
<TodoList filter="COMPLETED" /> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters