Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
4.2k views
in Technique[技术] by (71.8m points)

React如何做表单渲染优化

页面上有三个自定义表单单子组件,每个子组件都有五六个input,为了父组件渲染次数最少,我把数据放在了各个子组件,父组件提交的时候用ref去获取每个表单数据,但依然感觉在输入的时候不流畅,是不是需要把input也封装成一个组件,来优化渲染? 感觉react底层不至于连这点渲染都会卡吧。


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

把各个输入剥离开来,然后 memo 之类的减少渲染次数。


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...