Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
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
5 changes: 5 additions & 0 deletions packages/react-noop-renderer/src/ReactNoop.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import type {Fiber} from 'ReactFiber';
import type {UpdateQueue} from 'ReactFiberUpdateQueue';

var ReactCoroutine = require('ReactCoroutine');
var ReactFeatureFlags = require('ReactFeatureFlags');
var ReactFiberInstrumentation = require('ReactFiberInstrumentation');
var ReactFiberReconciler = require('react-reconciler');
Expand Down Expand Up @@ -452,6 +453,10 @@ var ReactNoop = {

flushSync: NoopRenderer.flushSync,

createCoroutine: ReactCoroutine.createCoroutine,

createYield: ReactCoroutine.createYield,

// Logs the current state of the tree.
dumpTree(rootID: string = DEFAULT_ROOT_ID) {
const root = roots.get(rootID);
Expand Down
27 changes: 8 additions & 19 deletions packages/react-reconciler/src/__tests__/ReactCoroutine-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,12 @@

var React;
var ReactNoop;
var ReactCoroutine;

describe('ReactCoroutine', () => {
beforeEach(() => {
jest.resetModules();
React = require('react');
ReactNoop = require('react-noop-renderer');
// TODO: can we express this test with only public API?
ReactCoroutine = require('ReactCoroutine');
});

function div(...children) {
Expand All @@ -43,7 +40,7 @@ describe('ReactCoroutine', () => {
// yielding. E.g. Continuation.yieldType = 123;
function Child({bar}) {
ops.push(['Child', bar]);
return ReactCoroutine.createYield({
return ReactNoop.createYield({
props: {
bar: bar,
},
Expand All @@ -67,11 +64,7 @@ describe('ReactCoroutine', () => {
// yielding. E.g. Parent.handler = HandleYields;
function Parent(props) {
ops.push('Parent');
return ReactCoroutine.createCoroutine(
props.children,
HandleYields,
props,
);
return ReactNoop.createCoroutine(props.children, HandleYields, props);
}

function App() {
Expand Down Expand Up @@ -104,7 +97,7 @@ describe('ReactCoroutine', () => {
}

function Child({bar}) {
return ReactCoroutine.createYield({
return ReactNoop.createYield({
props: {
bar: bar,
},
Expand All @@ -123,11 +116,7 @@ describe('ReactCoroutine', () => {
}

function Parent(props) {
return ReactCoroutine.createCoroutine(
props.children,
HandleYields,
props,
);
return ReactNoop.createCoroutine(props.children, HandleYields, props);
}

function App(props) {
Expand Down Expand Up @@ -163,7 +152,7 @@ describe('ReactCoroutine', () => {
class Child extends React.Component {
render() {
ops.push('Child');
return ReactCoroutine.createYield(Continuation);
return ReactNoop.createYield(Continuation);
}
componentWillUnmount() {
ops.push('Unmount Child');
Expand All @@ -180,7 +169,7 @@ describe('ReactCoroutine', () => {
class Parent extends React.Component {
render() {
ops.push('Parent');
return ReactCoroutine.createCoroutine(
return ReactNoop.createCoroutine(
this.props.children,
HandleYields,
this.props,
Expand Down Expand Up @@ -215,12 +204,12 @@ describe('ReactCoroutine', () => {
state = {value: 5};
render() {
instances[this.props.id] = this;
return ReactCoroutine.createYield(this.state.value);
return ReactNoop.createYield(this.state.value);
}
}

function App(props) {
return ReactCoroutine.createCoroutine(
return ReactNoop.createCoroutine(
[
<Counter key="a" id="a" />,
<Counter key="b" id="b" />,
Expand Down