Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add unmounting
  • Loading branch information
rthor committed Jan 22, 2017
commit d540fc99854388000bbb570d7812d21f926bf62a
1 change: 0 additions & 1 deletion scripts/fiber/tests-failing.txt
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ src/renderers/shared/shared/__tests__/refs-test.js
* Should increase refs with an increase in divs

src/test/__tests__/ReactTestUtils-test.js
* should have shallow unmounting
* lets you update shallowly rendered components
* can access the mounted component instance
* can shallowly render components with ref as function
Expand Down
1 change: 1 addition & 0 deletions scripts/fiber/tests-passing.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1732,6 +1732,7 @@ src/test/__tests__/ReactTestUtils-test.js
* should have shallow rendering
* should shallow render a functional component
* should throw for invalid elements
* should have shallow unmounting
* can shallow render to null
* can shallow render with a ref
* can shallowly render components with contextTypes
Expand Down
24 changes: 16 additions & 8 deletions src/test/ReactShallowRendererFiber.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ const reconciler = ReactFiberReconciler({
});

class ReactShallowRendererFiber {
container_ = (null: ?Container);
root_ = (null : ?Object)

render(element : React$Element<*>, context = emptyObject) {
invariant(
Expand All @@ -133,20 +133,28 @@ class ReactShallowRendererFiber {
'inspecting the rendered output, look at `el.props` directly instead.',
element.type
);
this.container_ = {

this.root_ = reconciler.createContainer({
context,
element: emptyObject,
};
});

const root = reconciler.createContainer(this.container_);
reconciler.updateContainer(element, root, null, null);
reconciler.updateContainer(element, this.root_, null, null);
return this.getRenderOutput();
}

unmount() {
if (this.root_ != null) {
reconciler.updateContainer(null, this.root_, null, () => {
this.root_ = null;
});
}
}

getRenderOutput() {
const component = this.container_ && this.container_.element;
return component === emptyObject ? null : component;
return this.root_ != null
? reconciler.findHostInstance(this.root_)
: null;
}
}

Expand Down