使用 create-react-app 构建环境(官方推荐使用npx)
npx create-react-app my-app
cd my-app
npx -p @storybook/cli sb init # 添加storybook
npm start
过了一遍官方教程,随便写点笔记如下:
- parent component to child component: props
- child component to parent component: callback function
- state 尽可能放 parent component,如果一个 component 没有 state 可以定义为 function
- 推荐使用immutable state,便于比对是否需要re-render