important sandbox
- https://codesandbox.io/embed/sandpack-project-neovm?fontsize=14&hidenavigation=1&theme=dark
- https://codesandbox.io/s/096fu?file=/App.js&from-sandpack=true
- https://codesandbox.io/s/kltjx?file=/Clock.js&from-sandpack=true
Rendering is a calculation, it shouldn’t try to “do” things. Can you express the same idea differently? - https://codesandbox.io/s/zitmn?file=/Profile.js&from-sandpack=true
- https://codesandbox.io/s/6omsb?file=/StoryTray.js&from-sandpack=true
- https://codesandbox.io/s/jvs4t?file=/App.js&from-sandpack=true
react&css交互: 一个跟随鼠标位置的红点 - https://codesandbox.io/s/bl2g8?file=/App.js&from-sandpack=true
- https://codesandbox.io/s/p016q?file=/App.js&from-sandpack=true
- https://codesandbox.io/s/ekpmc?file=/App.js&from-sandpack=true
- https://codesandbox.io/s/hqbeo?file=/App.js&from-sandpack=true
immer版本:https://codesandbox.io/s/hswzp?file=/App.js&from-sandpack=true - https://codesandbox.io/s/6cirx?file=/App.js&from-sandpack=true
- If a component has a lot of visual states, it can be convenient to show them all on one page:https://codesandbox.io/s/w17nw?file=/App.js&from-sandpack=true
- https://codesandbox.io/s/sandpack-project-forked-ips9y?file=/styles.css:0-780
👆每次更改状态后渲染的backgroundClassName和pictureClassName都是重新生成的
在html中,class=”类名+空格+类名”,表示该元素同时拥有两个类。 - https://codesandbox.io/s/s361t?file=/App.js&from-sandpack=true
- https://codesandbox.io/s/j8s81?file=/App.js&from-sandpack=true
对于position而言,x和y经常同时变动,so应该放在一个state中 - https://codesandbox.io/s/ovwew?file=/App.js&from-sandpack=true
immer:https://codesandbox.io/s/zrwnz?file=/App.js&from-sandpack=true - https://codesandbox.io/s/dkzvf?file=/App.js&from-sandpack=true
- https://beta.reactjs.org/learn/choosing-the-state-structure#challenges 这里的一堆challenge不太懂
- https://codesandbox.io/s/syek3?file=/data.js&from-sandpack=true搜索功能
- https://codesandbox.io/s/1mwzx?file=/App.js&from-sandpack=true这样重新渲染的会清零第二个state的值
React preserves a component’s state for as long as it’s being rendered at its position in the UI tree. If it gets removed, or a different component gets rendered at the same position, React discards its state. - https://codesandbox.io/s/eljps?file=/App.js&from-sandpack=true不要嵌套组件的生命方法
- https://codesandbox.io/s/uxzw2?file=/App.js&from-sandpack=true
- https://codesandbox.io/s/yofnl?file=/App.js&from-sandpack=true倒序的方法
- https://codesandbox.io/s/s1b2i?file=/App.js&from-sandpack=trueContext
- https://codesandbox.io/s/cpvgw?file=/App.js&from-sandpack=trueStopWatch
- https://codesandbox.io/s/xg4df?file=/App.js&from-sandpack=true利用ref清除timeoutId
- https://beta.reactjs.org/learn/referencing-values-with-refs#challenges challenge4⭐易错
- https://codesandbox.io/s/6vk2w?file=/App.js&from-sandpack=trueFocusing a text input
https://codesandbox.io/s/05rpo?file=/App.js&from-sandpack=trueAccessing another component’s DOM nodes[1]
https://codesandbox.io/s/3yi3d?file=/App.js&from-sandpack=true - https://codesandbox.io/s/vrc1y?file=/App.js&from-sandpack=true滚动父容器使当前容器被看到,用于切换视图
- https://codesandbox.io/s/825ww?file=/App.js&from-sandpack=true播放视频
- https://codesandbox.io/s/ln8zj?file=/App.js&from-sandpack=true轮播图
important chapter
- https://beta.reactjs.org/learn/keeping-components-pure
- https://beta.reactjs.org/learn/sharing-state-between-components这里的受控和非受控组件的区别
- https://beta.reactjs.org/learn/scaling-up-with-reducer-and-context Context+Reducer
DEEP DIVE
- https://medium.com/@ryardley/react-hooks-not-magic-just-arrays-cd4f1857236e
- https://beta.reactjs.org/learn/manipulating-the-dom-with-refs限制通过ref能对其他dom做的事情[1]
- https://beta.reactjs.org/learn/manipulating-the-dom-with-refsFlushing state updates synchronously with flushSync
立即刷新state使其同步
未完成文档
- https://beta.reactjs.org/learn/adding-interactivity#queueing-a-series-of-state-changes 所在处+其子文档 均未完成
- https://beta.reactjs.org/learn/escape-hatches 所在处未完成
| Syntax | Export statement | Import statement |
|---|---|---|
| Default | export default function Button() {} | import Button from ‘./button.js’; |
| Named | export function Button() {} | import { Button } from ‘./button.js’; |



实际上👇两个是等价的

Array.prototype.shift()
shift 方法移除索引为 0 的元素(即第一个元素),并返回被移除的元素,其他元素的索引值随之减 1。如果 length 属性的值为 0 (长度为 0),则返回 undefined。
React offers a “Strict Mode” in which it calls each component’s function twice during development. By calling the component functions twice, Strict Mode helps find components that break these rules.
但在 React 中,你可以在渲染时读取三种输入:props、state和context。 应始终将这些输入视为只读。
Hooks are special functions that let your components use React features
嵌套的标签都有点击事件的时候,比如点击
All events propagate in React except onScroll, which only works on the JSX tag you attach it to
If you want to prevent an event from reaching parent components, you need to call e.stopPropagation()
function Button({ onClick, children }) {return (<button onClick={e => {e.stopPropagation();onClick();}}>{children}</button>);}

Some browser events have default behavior associated with them. For example, a
