换种方式从新渲染,当异步加载自定义组件的时候
This commit is contained in:
parent
41aa5c2a04
commit
180882679e
|
@ -57,9 +57,11 @@ test('factory load Renderer on need', async () => {
|
|||
});
|
||||
|
||||
return Promise.resolve(({
|
||||
render,
|
||||
...rest
|
||||
}) => render('body', schema))
|
||||
retry
|
||||
}) => {
|
||||
retry();
|
||||
return null;
|
||||
})
|
||||
}
|
||||
})));
|
||||
await wait(200);
|
||||
|
|
|
@ -325,6 +325,7 @@ class SchemaRenderer extends React.Component<SchemaRendererProps, any> {
|
|||
super(props);
|
||||
this.refFn = this.refFn.bind(this);
|
||||
this.renderChild = this.renderChild.bind(this);
|
||||
this.reRender = this.reRender.bind(this);
|
||||
}
|
||||
|
||||
componentWillMount() {
|
||||
|
@ -406,6 +407,11 @@ class SchemaRenderer extends React.Component<SchemaRendererProps, any> {
|
|||
});
|
||||
}
|
||||
|
||||
reRender() {
|
||||
this.resolveSchema(this.props);
|
||||
this.forceUpdate();
|
||||
}
|
||||
|
||||
render():JSX.Element | null {
|
||||
let {
|
||||
schema,
|
||||
|
@ -430,7 +436,7 @@ class SchemaRenderer extends React.Component<SchemaRendererProps, any> {
|
|||
{...rest}
|
||||
getComponent={() => rest.env.loadRenderer(schema, $path)}
|
||||
$path={$path}
|
||||
render={this.renderChild}
|
||||
retry={this.reRender}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue