UNPKG

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