frintjs/frint

Proposal: MountApp component

開放

#433 建立於 2018年7月13日

 (0 則留言) (1 個反應) (0 位負責人)JavaScript (37 個分叉)batch import
help wantedproposal

倉庫指標

星標
 (746 顆星)
PR 合併指標
 (30 天內沒有已合併 PR)

描述

Currently

We use getMountableComponent(app) function, to get a component which has the app inside React's context.

Proposal

We can have a MountApp component, with usage like:

import { MountApp } from 'frint-react';

const fooApp; // instance

function BarComponent() {
  // render a given app with instance
  return <MountApp app={fooApp}>;

  // render a given app by name
  return <MountApp name="FooAppName" />

  // render any component against an app
  return <MountApp 
    name="FooAppName" /* or app={fooApp} */
    render={() => <SomeComponent />} 
  />;
}

Further usage

In frint-react: The MountApp component can then be used by Region component and render function internally too.

getMountableComponent can be deprecated.

Benefits

We don't have to depend on placing a Region with a name to mount an app somewhere. We can benefit from directly rendering an App somewhere without expecting any other App to share that region.

貢獻者指南