随笔分类 -  react

hooks
摘要:##useState const [count, setCount] = useState<number>(10) // 必须用setCount更新count,但是setCount是一个异步函数,在频繁地操作时会有一些问题 <button onClick={ () => { for (let i=1 阅读全文

posted @ 2022-10-08 00:35 In-6026 阅读(43) 评论(0) 推荐(0)

插槽
摘要:function App() { const name = 'Comp Name' return ( <Comp name={name}> <div slot="s1">solt1</div> <div slot="s2">solt2</div> </Comp> ) } import { React 阅读全文

posted @ 2022-10-06 23:32 In-6026 阅读(21) 评论(0) 推荐(0)

通信
摘要:##props ###函数(标签上传递,参数接收) interface IProps { name: string } interface IState {} function Comp(props: IProps) { const [state, setState] = useState<ISta 阅读全文

posted @ 2022-10-06 23:27 In-6026 阅读(40) 评论(0) 推荐(0)

受控组件,双向绑定
摘要:class Comp extends React.COmponent { state = { value: '' } change = (e) => { this.setState({ value = e.target.value }) } render() { return <input valu 阅读全文

posted @ 2022-10-06 17:28 In-6026 阅读(24) 评论(0) 推荐(0)

导航