核心概念
JSX
防止注入攻击
JSX 转换
const element = (
<h1 className="greeting">
Hello, world!
</h1>
);
// 上面的代码等同于
const element = React.createElement(
'h1',
{className: 'greeting'},
'Hello, world!'
);const element = {
type: 'h1',
props: {
className: 'greeting',
children: 'Hello, world!'
}
};createRoot()
组件 & Props
props
类组件 & state
state
state 的使用注意事项:
setState()
事件处理
类组件 this 绑定
回调函数中传入额外参数
key
受控组件
状态提升
Last updated