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

support react's hydrate for enzyme-adapter-react-16 #1316

Closed
brucewpaul opened this issue Nov 1, 2017 · 7 comments
Closed

support react's hydrate for enzyme-adapter-react-16 #1316

brucewpaul opened this issue Nov 1, 2017 · 7 comments
Labels
API: mount feature request Issues asking for stuff that would be semver-minor package: react adapter: 16

Comments

@brucewpaul
Copy link
Contributor

It would be great to support testing react's hydrate method as opposed to just the render method. This could maybe be done via an options argument?

cc @ljharb

@ljharb
Copy link
Member

ljharb commented Nov 1, 2017

With an empty DOM node, won't hydrate and render be identical?

@brucewpaul
Copy link
Contributor Author

Ya I think so, but this would be able to specifically test server side rendering of a component.

cc @goatslacker

@ljharb
Copy link
Member

ljharb commented Nov 1, 2017

Certainly mount invokes ReactDOM.render; an adapter option could be used in the v16+ adapter to specify ReactDOM.hydrate be used.

I'm just not sure what the point would be - all we'd be doing is testing ReactDOM itself, since hydrate and render theoretically do the same thing on an empty container.

@goatslacker
Copy link
Contributor

There's currently a warning when you try to render() SSR'd markup, so it would at the very least silence that warning.

@ljharb
Copy link
Member

ljharb commented Nov 7, 2017

In that case, maybe it'd be better to always use hydrate in the React 16 adapter here?

@goatslacker
Copy link
Contributor

We should have both, for non server rendered content I think you want to use render

@ljharb
Copy link
Member

ljharb commented Nov 8, 2017

OK, talked to @goatslacker about this - how about a mount option, parallel to attachTo, called hydrateIn? Both options are mutually exclusive; both take a DOM element; hydrateIn calls hydrate on the adapter if present and falls back to render if not?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API: mount feature request Issues asking for stuff that would be semver-minor package: react adapter: 16
Projects
None yet
Development

No branches or pull requests

3 participants