-
Notifications
You must be signed in to change notification settings - Fork 29.9k
/
experimental-tests.tsx
38 lines (30 loc) · 1.05 KB
/
experimental-tests.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import React = require('react');
import ReactDOM = require('react-dom');
import 'react-dom/experimental';
function createRoot() {
const root = ReactDOM.unstable_createRoot(document);
// NOTE: I don't know yet how to use this; this is just the type it expects
// in reality it will do nothing because the root isn't hydrate: true
ReactDOM.unstable_scheduleHydration(document);
root.render(<div>initial render</div>, () => {
console.log('callback');
});
}
function createBlockingRoot() {
const root = ReactDOM.unstable_createBlockingRoot(document, {
hydrate: true,
});
root.render(<div>initial render</div>, () => {
console.log('callback');
});
}
function updates() {
// $ExpectType 0
ReactDOM.unstable_discreteUpdates((): 0 => 0);
// $ExpectType number
ReactDOM.unstable_discreteUpdates((foo: number) => foo, 1);
// $ExpectError
ReactDOM.unstable_discreteUpdates((foo: number) => foo);
ReactDOM.unstable_flushDiscreteUpdates();
ReactDOM.unstable_flushControlled(() => {});
}