Skip to content

Commit

Permalink
Unforked renderApplication()
Browse files Browse the repository at this point in the history
Summary: This allows toggling fabric renderer via the same renderApplication()

Reviewed By: mdvacca

Differential Revision: D7682524

fbshipit-source-id: 59be1d2bea15f5e13e64e2d72304d79f9cb7d084
  • Loading branch information
fkgozali authored and facebook-github-bot committed Apr 19, 2018
1 parent dc83678 commit 60b0513
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 80 deletions.
4 changes: 1 addition & 3 deletions Libraries/ReactNative/AppContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ type Props = {|
* suppresses an error when upgrading Flow's support for React. To see the
* error delete this comment and run Flow. */
children?: React.Children,
fabric?: boolean,
rootTag: number,
WrapperComponent?: ?React.ComponentType<*>,
|};
Expand Down Expand Up @@ -91,8 +90,7 @@ class AppContainer extends React.Component<Props, State> {
render(): React.Node {
let yellowBox = null;
if (__DEV__) {
if (!global.__RCTProfileIsProfiling && !this.props.fabric) {
// TODO: Fabric doesn't support YellowBox.
if (!global.__RCTProfileIsProfiling) {
const YellowBox = require('YellowBox');
yellowBox = <YellowBox />;
}
Expand Down
19 changes: 2 additions & 17 deletions Libraries/ReactNative/AppRegistry.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,6 @@ const infoLog = require('infoLog');
const invariant = require('fbjs/lib/invariant');
const renderApplication = require('renderApplication');

// Renderer provider must be supplied by each app. If none, traditional
// renderApplication() will be used.
let fabricRendererProvider: ?() => typeof renderApplication = null;

type Task = (taskData: any) => Promise<void>;
type TaskProvider = () => Task;
export type ComponentProvider = () => React$ComponentType<any>;
Expand Down Expand Up @@ -102,19 +98,12 @@ const AppRegistry = {
runnables[appKey] = {
componentProvider,
run: appParameters => {
let renderFunc = renderApplication;
if (appParameters.fabric) {
invariant(
fabricRendererProvider != null,
'A Fabric renderer provider must be set to render Fabric components',
);
renderFunc = fabricRendererProvider();
}
renderFunc(
renderApplication(
componentProviderInstrumentationHook(componentProvider),
appParameters.initialProps,
appParameters.rootTag,
wrapperComponentProvider && wrapperComponentProvider(appParameters),
appParameters.fabric,
);
},
};
Expand Down Expand Up @@ -249,10 +238,6 @@ const AppRegistry = {
NativeModules.HeadlessJsTaskSupport.notifyTaskFinished(taskId);
});
},

setFabricRendererProvider(provider: () => typeof renderApplication): void {
fabricRendererProvider = provider;
},
};

BatchedBridge.registerCallableModule('AppRegistry', AppRegistry);
Expand Down
8 changes: 7 additions & 1 deletion Libraries/ReactNative/renderApplication.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

const AppContainer = require('AppContainer');
const React = require('React');
const ReactFabric = require('ReactFabric');
const ReactNative = require('ReactNative');

const invariant = require('fbjs/lib/invariant');
Expand All @@ -25,6 +26,7 @@ function renderApplication<Props: Object>(
initialProps: Props,
rootTag: any,
WrapperComponent?: ?React.ComponentType<*>,
fabric?: boolean,
) {
invariant(rootTag, 'Expect to have a valid rootTag, instead got ', rootTag);

Expand All @@ -49,7 +51,11 @@ function renderApplication<Props: Object>(
renderable = <AsyncMode>{renderable}</AsyncMode>;
}

ReactNative.render(renderable, rootTag);
if (fabric) {
ReactFabric.render(renderable, rootTag);
} else {
ReactNative.render(renderable, rootTag);
}
}

module.exports = renderApplication;
59 changes: 0 additions & 59 deletions Libraries/ReactNative/renderFabricSurface.js

This file was deleted.

0 comments on commit 60b0513

Please sign in to comment.