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

Feat: Should rerender component when called render again? #32

Open
imcuttle opened this issue Nov 7, 2018 · 3 comments
Open

Feat: Should rerender component when called render again? #32

imcuttle opened this issue Nov 7, 2018 · 3 comments
Assignees

Comments

@imcuttle
Copy link

imcuttle commented Nov 7, 2018

The code rejected rerender from outside by calling render

preact-habitat/src/lib.js

Lines 123 to 125 in 6969949

if (hostNode._habitat) {
return;
}

const { render } = habitat(MyComponent)

render({
   selector: '.app',
})

// the blow renderer does not work
render({
  selector: '.app',
  defaultProps: { foo: 'bar' }
})
@zouhir
Copy link
Owner

zouhir commented Nov 14, 2018

I never had use case where this is useful, but, when a developer explicitly calls render() I think we should do it. I will have this in mind, thanks.

@zouhir
Copy link
Owner

zouhir commented Oct 24, 2021

I will add force option.

@zouhir zouhir self-assigned this Oct 24, 2021
@remorses
Copy link

remorses commented Sep 27, 2022

This bug means that you cannot use preact-habitat on the same selector more than once

for example if someone is using this library for 2 widgets on their site (usually widgets will use the body selector), only the first one will work

Edit: turns out it doesn't matter anyway because preact renders a tree only once for each root container, i needed to do this:

// preact will render only once for each container
const container = document.createElement('div')
document.body.appendChild(container)
render(<App />, container)

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

3 participants