Skip to content
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

Lifecycle rendered with Portals #351

Open
matuzalemsteles opened this issue Jan 26, 2018 · 2 comments
Open

Lifecycle rendered with Portals #351

matuzalemsteles opened this issue Jan 26, 2018 · 2 comments

Comments

@matuzalemsteles
Copy link
Contributor

When there is an implementation of Portals in the component is used the lifecycle rendered is called before the rendering actually takes place in the DOM.

See ClayDropdown as an example.

Expected behavior

When a render or change occurs in the DOM, the lifecycle rendered is expected to be called later.

Current behavior

When a change or a render with Portal happens the lifecycle rendered is called before the change actually takes place in the DOM.

@robframpton
Copy link

Hey @matuzalemsteles

This one is a bit tricky, because for the case of ClayDropdownBase, the ClayPortal component isn't actually providing the markup, rather the markup is being passed from ClayDropdownBase via the content parameter.

If you add the rendered lifecycle method to ClayDropdownBase, you should see that it is fired after the menu markup has updated.

rendered() {
	console.log(this.refs.portal.element);
}

@matuzalemsteles
Copy link
Contributor Author

Hey @Robert-Frampton, thanks for clarifying.

I think the case was to know when it was actually the changes being seen in the DOM. How to use ClayPortal and is another component and I can not tell when it was rendered its content. It happened that when I updated something in STATE and the content that went to ClayPortal used this data the rendered of ClayDropdownBase gave the impression that those changes were already seen in the DOM, and have not yet been.

To solve the problem I had to add the lifecycle rendered in ClayPortal by issuing an event so I can listen inside ClayDropdownBase or simply listen to the rendered event of ClayPortal.

this.refs.portal.on('rendered', this.handleRenderedPortal_.bind(this));

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