hm-react-cli
Version:
Create a Huimei React project by module
37 lines (31 loc) • 866 B
JavaScript
import { useEffect, Component } from 'react';
export default class Child extends Component {
constructor(props) {
super(props);
this.Child2 = React.createRef();
}
componentDidMount() {
this.Child2.current.innerHTML = '<div>123</div>';
}
componentDidUpdate() {
// this.Child2.current.innerHTML = '<div>123</div>';
}
shouldComponentUpdate(nextProps, nextState) {
// if (this.props.count !== nextProps.count) {
// return true;
// }
}
render() {
return (
<>
{/* <span>{count}</span> */}
<div id="Child">
<span>span1</span>
<span id="Child2" ref={this.Child2}>
child2
</span>
</div>
</>
);
}
}