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
function PageSelector() { | |
const [page, setPage] = useState(1); | |
useEffect(() => { | |
// Get page params from URLSearchParams | |
const urlParams = new URLSearchParams(window.location.search); | |
const params = Object.fromEntries(urlSearchParams.entries()); | |
// Update page state if exist | |
if (params?.page) { | |
setPage(params.page); | |
} |
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
Show hidden characters
function CommentsList() { | |
const [comments, setComments] = useState([]); | |
useEffect(() => { | |
// Fetch Comments | |
fetchComments().then(response => { | |
// ... | |
setComments(response.data); | |
}); | |
}, []); | |
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
function Counter() { | |
const [count, setCount] = useState(0); | |
useEffect(() => { | |
const id = setInterval(() => { | |
setCount(c => c + 1); | |
}, 1000); | |
}, []); | |
return <h1>{count}</h1>; |
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
// react/index.d.ts | |
type DependencyList = ReadonlyArray<any>; | |
function useEffect(effect: EffectCallback, dep?: DependencyList): void; |
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
# Your init script | |
# | |
# Atom will evaluate this file each time a new window is opened. It is run | |
# after packages are loaded/activated and after the previous editor state | |
# has been restored. | |
# | |
# An example hack to log to the console when each text editor is saved. | |
# | |
# atom.workspace.observeTextEditors (editor) -> | |
# editor.onDidSave -> |