UNPKG

1.9 kBJavaScriptView Raw
1/**
2 * Copyright (c) 2013-present, Facebook, Inc.
3 *
4 * This source code is licensed under the MIT license found in the
5 * LICENSE file in the root directory of this source tree.
6 *
7 *
8 */
9
10'use strict';
11
12var _require = require('./ReactFiberRoot'),
13 createFiberRoot = _require.createFiberRoot;
14
15var ReactFiberScheduler = require('./ReactFiberScheduler');
16
17module.exports = function (config) {
18 var _ReactFiberScheduler = ReactFiberScheduler(config),
19 scheduleWork = _ReactFiberScheduler.scheduleWork,
20 performWithPriority = _ReactFiberScheduler.performWithPriority;
21
22 return {
23 mountContainer: function (element, containerInfo) {
24 var root = createFiberRoot(containerInfo);
25 var container = root.current;
26 // TODO: Use pending work/state instead of props.
27 // TODO: This should not override the pendingWorkPriority if there is
28 // higher priority work in the subtree.
29 container.pendingProps = element;
30
31 scheduleWork(root);
32
33 // It may seem strange that we don't return the root here, but that will
34 // allow us to have containers that are in the middle of the tree instead
35 // of being roots.
36 return container;
37 },
38 updateContainer: function (element, container) {
39 // TODO: If this is a nested container, this won't be the root.
40 var root = container.stateNode;
41 // TODO: Use pending work/state instead of props.
42 root.current.pendingProps = element;
43
44 scheduleWork(root);
45 },
46 unmountContainer: function (container) {
47 // TODO: If this is a nested container, this won't be the root.
48 var root = container.stateNode;
49 // TODO: Use pending work/state instead of props.
50 root.current.pendingProps = [];
51
52 scheduleWork(root);
53 },
54
55
56 performWithPriority: performWithPriority,
57
58 getPublicRootInstance: function (container) {
59 return null;
60 }
61 };
62};
\No newline at end of file