Unforked renderApplication()

Summary: This allows toggling fabric renderer via the same renderApplication()

Reviewed By: mdvacca

Differential Revision: D7682524

fbshipit-source-id: 59be1d2bea15f5e13e64e2d72304d79f9cb7d084
This commit is contained in:
Kevin Gozali
2018-04-19 11:03:50 -07:00
committed by Facebook Github Bot
parent dc836780cb
commit 60b05133ba
4 changed files with 10 additions and 80 deletions

View File

@@ -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>;
@@ -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,
);
},
};
@@ -249,10 +238,6 @@ const AppRegistry = {
NativeModules.HeadlessJsTaskSupport.notifyTaskFinished(taskId);
});
},
setFabricRendererProvider(provider: () => typeof renderApplication): void {
fabricRendererProvider = provider;
},
};
BatchedBridge.registerCallableModule('AppRegistry', AppRegistry);