frintjs/frint
在 GitHub 查看frint-router-react: Support rendering already registered Apps by name
Open
#373 建立於 2017年11月14日
featurehelp wanted
描述
Currently
Along with Components, we also support rendering Apps with <Route>:
import { Route } from 'frint-router-react';
import MyApp from './apps/MyApp';
function MyComponent() {
return (
<div>
<Route path="/about" app={MyApp} />
</div>
);
}
Whenever the route is active, it handles instantiating the App and then rendering it. And when the route is not active and unmounted, it will destroy the App instance.
Proposed feature
FrintJS allows Child Apps to be registered:
window.app.registerApp(MyApp);
This instantiates the App and keeps it in the local registry.
We can re-use the same instance in routing too if needed:
import { Route } from 'frint-router-react';
function MyComponent() {
return (
<div>
<Route path="/about" app="MyApp" />
</div>
);
}
Instead of supporting only classes for app, we can also additionally support strings (App names). This way, routes can be enabled to render the same App's instance and they don't need to instantiated/destroyed every time the Route becomes active.
It gives developers a choice based on their needs.