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

render differs from react #1954

Closed
dy opened this issue Sep 27, 2019 · 2 comments
Closed

render differs from react #1954

dy opened this issue Sep 27, 2019 · 2 comments

Comments

@dy
Copy link

dy commented Sep 27, 2019

Question/bug report.
There's discrepancy of preact and react render.
If we have simple example (see codesandbox)

import { render } from "preact";

let el = document.getElementById("root");
el.innerHTML = "<a>x</a>";

render(<div>y</div>, root);

Preact appends <div>y</div> to root (unexpected!), whereas react mutates it.

Maybe related to #1781 - same issue is with portals - is that expected that preact keeps existing html?

@JoviDeCroock
Copy link
Member

It's not related to that, for full react compat you should do the following: https://codesandbox.io/s/gifted-pike-ktv4t

Here we import form compat, a layer meant to ensure compatability with React.

@marvinhagemeister
Copy link
Member

This is resolved in the upcoming version that should come out really soon. Preact 8 works differently, because it has a third argument for the render function that gives you the behavior of React.

render(<div>y</div>, root, root.firstChild);

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