piral-native
Version:
The Piral framework for use in React Native.
30 lines • 1.12 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.renderInstance = void 0;
const tslib_1 = require("tslib");
const react_native_1 = require("react-native");
const app_1 = require("./app");
function noChange(config) {
return config;
}
/**
* Sets up a new Piral instance and renders it using the provided options.
* Can be used as simple as calling the function directly without any
* arguments.
* @param appName The name of the application.
* @param options The options to use when setting up the Piral instance.
* @example
```ts
import { renderInstance } from 'piral-native';
renderInstance();
```
*/
function renderInstance(appName, options) {
const { layout, errors, middleware = noChange } = options, config = tslib_1.__rest(options, ["layout", "errors", "middleware"]);
const { app, instance } = (0, app_1.getAppInstance)(middleware(config), { layout, errors });
const App = () => app;
react_native_1.AppRegistry.registerComponent(appName, () => App);
return instance;
}
exports.renderInstance = renderInstance;
//# sourceMappingURL=render.js.map