fix: 提前 simulator mount 的时间点, 修复极低概率出现的 style 丢失现象

This commit is contained in:
力皓 2021-04-28 10:03:00 +08:00
parent ca4222a98e
commit b65460f029

View File

@ -23,9 +23,10 @@ export class BuiltinSimulatorHostView extends Component<SimulatorHostProps> {
constructor(props: any) {
super(props);
const { project } = this.props;
const { project, onMount } = this.props;
this.host = (project.simulator as BuiltinSimulatorHost) || new BuiltinSimulatorHost(project);
this.host.setProps(this.props);
onMount?.(this.host);
}
shouldComponentUpdate(nextProps: BuiltinSimulatorProps) {
@ -33,12 +34,6 @@ export class BuiltinSimulatorHostView extends Component<SimulatorHostProps> {
return false;
}
componentDidMount() {
if (this.props.onMount) {
this.props.onMount(this.host);
}
}
render() {
return (
<div className="lc-simulator">