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
const addCount = () => ({ | |
type: "ADD_COUNT" | |
}); | |
export default { | |
addCount | |
}; |
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
enum ActionType { | |
ADD_TODO = 'add_todo', | |
ADD_TODO_SUCCESS = 'add_todo_success', | |
ADD_TODO_ERROR = 'add_todo_error', | |
} | |
interface TodoState { | |
loading: boolean; | |
error: string | null; | |
data: string[]; |
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
enum ActionType { | |
ADD_TODO = 'add_todo', | |
ADD_TODO_SUCCESS = 'add_todo_success', | |
ADD_TODO_ERROR = 'add_todo_error', | |
} | |
interface TodoState { | |
loading: boolean; | |
error: string | null; | |
data: string[]; |
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
const ADD_TODO = 'add_todo'; | |
const ADD_TODO_SUCCESS = 'add_todo_success'; | |
const ADD_TODO_ERROR = 'add_todo_error'; | |
const initialState = { | |
loading: false, | |
error: null, | |
data: [], | |
} |
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
import { useState, useRef, useEffect } from 'react'; | |
const Search: React.FC = () => { | |
const inputRef = useRef<HTMLInputElement | null>(null); | |
const [name, setName] = useState(''); | |
useEffect(() => { | |
if (!inputRef.current) { | |
return; | |
} |
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
import { useState, useRef, useEffect } from 'react'; | |
const Search = () => { | |
const inputRef = useRef(null); | |
const [name, setName] = useState(''); | |
useEffect(() => { | |
inputRef.current.focus(); | |
}, []); | |
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
const EventComponent: React.FC = () => { | |
const onChange = (event: React.ChangeEvent<HTMLInputElement>) => { | |
console.log(event.target.value); | |
}; | |
const onDragStart = (event: React.DragEvent<HTMLDivElement>) => { | |
console.log(event); | |
}; | |
return ( |
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
const EventComponent = () => { | |
const onChange = (event) => { | |
console.log(event); | |
}; | |
return ( | |
<div> | |
<input onChange={onChange} /> | |
</div> | |
); |