【发布时间】:2020-03-31 11:56:27
【问题描述】:
在 React 中,当我从 AutoComplete 中选择任何内容时,它会重新渲染 Input 元素,我如何才能阻止它重新渲染仅 Input 元素但重新渲染其他所有内容?
到目前为止我已经尝试过:
要使用 shouldComponentUpdate() 但要么我使用不正确,要么其他东西不起作用:How to stop the google map from re rendering and keeping just the values in input fields when marker is placed on different locations?
并按照此处的建议将 AutoComplete 组件与 Class 组件分开放置:https://github.com/tomchentw/react-google-maps/issues/220
【问题讨论】:
-
将 state 关键字更改为您的姓名或其他您在 state 中设置的数据不一定要在您的 state 中,最好不要在 state 中以获得更好的性能。我猜想如果您将自动完成组件与 AsyncMap 分开,您的问题将如何解决。
-
你怎么知道通过分离它会修复它?
标签: reactjs react-component react-google-maps