Skip to content

Rendering elements inside dynamic parent without child remounting #10516

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
0x2E757 opened this issue Aug 23, 2017 · 1 comment
Closed

Rendering elements inside dynamic parent without child remounting #10516

0x2E757 opened this issue Aug 23, 2017 · 1 comment

Comments

@0x2E757
Copy link

0x2E757 commented Aug 23, 2017

Is it possible to change element's parent so element will be just "moved" from current parent to new?

@StoreConnect("params")
class ParentRenderer extends React.Component<any, any> {
    public render(): any {
        const { children, params: { parent } } = this.props;
        if (parent) 
            return React.createElement(parent, undefined, children);
        }
        return children;
    }
}

Using this code, when ParentRenderer's children is changed the parent is not re-rendered. This is perfect. But if we change parent (actually it is being changed by new children, because each children's componentWillMount is updating store and sets required parent) will happen:

  1. old children unmounting, new children mounting
  2. old parent unmounting, current children unmounting
  3. new parent mounting, current children mounting

The simplest way to solve this (and the only I see) — change children and parent in the same time. But I would like to know is there any other options, because changing children and parent in the same time is breaking my app, and also there is lack of information in the internet about this or similar cases (or my googling skills are broken).

@gaearon
Copy link
Collaborator

gaearon commented Aug 23, 2017

No, this is not currently supported.
Existing issue: #3965.

@gaearon gaearon closed this as completed Aug 23, 2017
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

No branches or pull requests

2 participants