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 requests, json | |
token = 'XXX' | |
databaseId = 'XXX' | |
headers = { | |
"Authorization": "Bearer " + token, | |
"Content-Type": "application/json", | |
"Notion-Version": "2021-05-13" |
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
npm install react@alpha react-dom@alpha |
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 App = () => { | |
return ( | |
<Suspense fallback={<Loading />}> | |
<SuspendedComponent /> | |
<Sibling /> | |
</Suspense> | |
); | |
}; |
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 { Suspense, SuspenseList } from "react"; | |
const App = () => { | |
return ( | |
<SuspenseList revealOrder="forwards"> | |
<Suspense fallback={"Loading..."}> | |
<ProfilePicture id={1} /> | |
</Suspense> | |
<Suspense fallback={"Loading..."}> | |
<ProfilePicture id={2} /> |
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 { useDeferredValue } from "react"; | |
// ... | |
const [text, setText] = useState("text"); | |
const deferredText = useDeferredValue(text, { timeoutMs: 2000 }); |
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 App = () => { | |
// ... | |
const [isPending, startTransition] = useTransition({ timeoutMs: 2000 }); | |
startTransition(() => { | |
setSearchQuery(input); | |
}); | |
// ... |
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 { startTransition } from "react"; | |
// ... | |
// Urgent -> show updated input | |
setInputValue(input); | |
// Transition (non-urgent) -> show search | |
startTransition(() => { | |
setSearchQuery(input); |
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
// Old | |
ReactDOM.hydrate(<App />, container); | |
// New | |
const root = ReactDOM.createRoot(container, { hydrate: true }); | |
root.render(<App />); |
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
// Old | |
ReactDOM.render(<App />, container, () => console.log("renderered")); | |
// New | |
const App = ({ callback }) => { | |
return ( | |
<div ref={callback}> | |
<h1>Hello World</h1> | |
</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
import ReactDOM from "react-dom"; | |
import App from "App"; | |
const container = document.getElementById("app"); | |
// Old | |
ReactDOM.render(<App />, container); | |
// New | |
const root = ReactDOM.createRoot(container); |
NewerOlder