Skip to content

Conversation

@elboman
Copy link
Member

@elboman elboman commented May 9, 2018

In order to force a re-mount of the component, it creates a timestamp when the viewConfig is updated, and uses it as key prop for the component.

React forces the component to remount whenever the key props changes.

@christopherthielen
Copy link
Member

This use of key is really simple and pretty clever. If it ever causes problems, we can always switch to a mechanism which creates a new functional component when the view config is updated. Something like:

    this.uiViewData.config = newConfig;
    let props = { ...resolves, transition: trans };

    const RoutedComponent = newConfig && newConfig.viewDecl && newConfig.viewDecl.component;
    const newComponent = RoutedComponent ? (props) => <RoutedComponent {...props }/> : null;

    this.setState({
      component: newComponent || 'div',
      props: newComponent ? props : {},
      loaded: !!newComponent,
    });

@christopherthielen christopherthielen merged commit 1bae466 into master May 14, 2018
@elboman elboman deleted the remount branch May 15, 2018 22:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants