mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-04-24 04:16:00 +08:00
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:
committed by
Facebook Github Bot
parent
dc836780cb
commit
60b05133ba
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user