-
Notifications
You must be signed in to change notification settings - Fork 47k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce new API for creating roots. Only root.render and root.unmount are implemented. Later we'll add root.prerender, and support for lazy roots (roots with DOM containers that resolve lazily).
- Loading branch information
Showing
2 changed files
with
67 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/** | ||
* Copyright (c) 2013-present, Facebook, Inc. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
* | ||
* @emails react-core | ||
*/ | ||
|
||
'use strict'; | ||
|
||
var React = require('react'); | ||
var ReactDOM = require('react-dom'); | ||
|
||
describe('ReactDOMRoot', () => { | ||
let container; | ||
|
||
beforeEach(() => { | ||
container = document.createElement('div'); | ||
}); | ||
|
||
it('renders children', () => { | ||
const root = ReactDOM.createRoot(container); | ||
root.render(<div>Hi</div>); | ||
expect(container.textContent).toEqual('Hi'); | ||
}); | ||
|
||
it('unmounts children', () => { | ||
const root = ReactDOM.createRoot(container); | ||
root.render(<div>Hi</div>); | ||
expect(container.textContent).toEqual('Hi'); | ||
root.unmount(); | ||
expect(container.textContent).toEqual(''); | ||
}); | ||
}); |