mirror of
https://github.com/seigler/presentation-react-state-management
synced 2025-07-26 01:06:10 +00:00
rename mini-apps
This commit is contained in:
parent
6ff5051f79
commit
a5abe75007
5 changed files with 12 additions and 12 deletions
|
@ -1,11 +1,11 @@
|
|||
import { UseState } from './useState'
|
||||
import { UseReducer } from './useReducer'
|
||||
import { UseContext } from './useContext'
|
||||
import { UseSignal } from './useSignal'
|
||||
import { TodoUseState } from './todoUseState'
|
||||
import { TodoUseReducer } from './todoUseReducer'
|
||||
import { TodoUseContext } from './todoUseContext'
|
||||
import { TodoSignal } from './todoSignal'
|
||||
|
||||
export const strategies = [
|
||||
{ name: 'useState', component: UseState },
|
||||
{ name: 'useReducer', component: UseReducer },
|
||||
{ name: 'useContext', component: UseContext },
|
||||
{ name: 'useSignal', component: UseSignal }
|
||||
{ name: 'useState', component: TodoUseState },
|
||||
{ name: 'useReducer', component: TodoUseReducer },
|
||||
{ name: 'useContext', component: TodoUseContext },
|
||||
{ name: 'signals', component: TodoSignal }
|
||||
]
|
||||
|
|
|
@ -35,7 +35,7 @@ function updateTodo(value: Todo) {
|
|||
todos.value = todos.value.map((t) => (t.id === value.id ? value : t))
|
||||
}
|
||||
|
||||
export function UseSignal() {
|
||||
export function TodoSignal() {
|
||||
useEffect(() => {
|
||||
// run once when mounted
|
||||
localforage.getItem('react-state-management/todos', (_err, value) => {
|
|
@ -43,7 +43,7 @@ const TodoContext = React.createContext({
|
|||
dispatchTodoAction: (TodoAction) => {}
|
||||
})
|
||||
|
||||
export function UseContext() {
|
||||
export function TodoUseContext() {
|
||||
const [isLoading, setLoading] = useState(true)
|
||||
const [todos, dispatchTodoAction] = useReducer(reducer, [])
|
||||
const [newTodoText, setNewTodoText] = useState('')
|
|
@ -38,7 +38,7 @@ const reducer = (state: Todo[], action: TodoAction) => {
|
|||
}
|
||||
}
|
||||
|
||||
export function UseReducer() {
|
||||
export function TodoUseReducer() {
|
||||
const [isLoading, setLoading] = useState(true)
|
||||
const [todos, dispatchTodoAction] = useReducer(reducer, [])
|
||||
const [newTodoText, setNewTodoText] = useState('')
|
|
@ -7,7 +7,7 @@ type Todo = {
|
|||
status: 'incomplete' | 'complete'
|
||||
}
|
||||
|
||||
export function UseState() {
|
||||
export function TodoUseState() {
|
||||
const [isLoading, setLoading] = useState(true)
|
||||
const [todos, setTodos] = useState<Todo[]>([])
|
||||
const [newTodoText, setNewTodoText] = useState('')
|
Loading…
Add table
Add a link
Reference in a new issue