rename mini-apps

This commit is contained in:
Joshua Seigler 2022-10-12 13:47:21 -04:00
parent 6ff5051f79
commit a5abe75007
No known key found for this signature in database
5 changed files with 12 additions and 12 deletions

View file

@ -1,11 +1,11 @@
import { UseState } from './useState' import { TodoUseState } from './todoUseState'
import { UseReducer } from './useReducer' import { TodoUseReducer } from './todoUseReducer'
import { UseContext } from './useContext' import { TodoUseContext } from './todoUseContext'
import { UseSignal } from './useSignal' import { TodoSignal } from './todoSignal'
export const strategies = [ export const strategies = [
{ name: 'useState', component: UseState }, { name: 'useState', component: TodoUseState },
{ name: 'useReducer', component: UseReducer }, { name: 'useReducer', component: TodoUseReducer },
{ name: 'useContext', component: UseContext }, { name: 'useContext', component: TodoUseContext },
{ name: 'useSignal', component: UseSignal } { name: 'signals', component: TodoSignal }
] ]

View file

@ -35,7 +35,7 @@ function updateTodo(value: Todo) {
todos.value = todos.value.map((t) => (t.id === value.id ? value : t)) todos.value = todos.value.map((t) => (t.id === value.id ? value : t))
} }
export function UseSignal() { export function TodoSignal() {
useEffect(() => { useEffect(() => {
// run once when mounted // run once when mounted
localforage.getItem('react-state-management/todos', (_err, value) => { localforage.getItem('react-state-management/todos', (_err, value) => {

View file

@ -43,7 +43,7 @@ const TodoContext = React.createContext({
dispatchTodoAction: (TodoAction) => {} dispatchTodoAction: (TodoAction) => {}
}) })
export function UseContext() { export function TodoUseContext() {
const [isLoading, setLoading] = useState(true) const [isLoading, setLoading] = useState(true)
const [todos, dispatchTodoAction] = useReducer(reducer, []) const [todos, dispatchTodoAction] = useReducer(reducer, [])
const [newTodoText, setNewTodoText] = useState('') const [newTodoText, setNewTodoText] = useState('')

View file

@ -38,7 +38,7 @@ const reducer = (state: Todo[], action: TodoAction) => {
} }
} }
export function UseReducer() { export function TodoUseReducer() {
const [isLoading, setLoading] = useState(true) const [isLoading, setLoading] = useState(true)
const [todos, dispatchTodoAction] = useReducer(reducer, []) const [todos, dispatchTodoAction] = useReducer(reducer, [])
const [newTodoText, setNewTodoText] = useState('') const [newTodoText, setNewTodoText] = useState('')

View file

@ -7,7 +7,7 @@ type Todo = {
status: 'incomplete' | 'complete' status: 'incomplete' | 'complete'
} }
export function UseState() { export function TodoUseState() {
const [isLoading, setLoading] = useState(true) const [isLoading, setLoading] = useState(true)
const [todos, setTodos] = useState<Todo[]>([]) const [todos, setTodos] = useState<Todo[]>([])
const [newTodoText, setNewTodoText] = useState('') const [newTodoText, setNewTodoText] = useState('')