該組件的渲染方法確實使用了提供給組件的任何道具。當涉及到調用渲染方法時,ReactJS是否「聰明」?
當道具改變時,組件是否會重新渲染?
class MyComponent extends React.Component {
constructor(props) {
super(props);
const { propValue } = props;
// do something with propValue...
}
render() {
return (
<div>foo</div>
);
}
}
[相關(http://lucybain.com/blog/2017/react-js-when-to-rerender/) 。 – PeterMader