Skip to content

Commit f9776cf

Browse files
committed
add hydrate method that uses reactDOM.hydrate
1 parent 83c77b6 commit f9776cf

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

packages/enzyme-adapter-react-16/src/ReactSixteenAdapter.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,22 @@ class ReactSixteenAdapter extends EnzymeAdapter {
175175
instance.setChildProps(el.props, context, callback);
176176
}
177177
},
178+
hydrate(el, context, callback) {
179+
if (instance === null) {
180+
const ReactWrapperComponent = createMountWrapper(el, options);
181+
const wrappedEl = React.createElement(ReactWrapperComponent, {
182+
Component: el.type,
183+
props: el.props,
184+
context,
185+
});
186+
instance = ReactDOM.hydrate(wrappedEl, domNode);
187+
if (typeof callback === 'function') {
188+
callback();
189+
}
190+
} else {
191+
instance.setChildProps(el.props, context, callback);
192+
}
193+
},
178194
unmount() {
179195
ReactDOM.unmountComponentAtNode(domNode);
180196
instance = null;

0 commit comments

Comments
 (0)