Skip to content

Commit

Permalink
Readme and self review
Browse files Browse the repository at this point in the history
  • Loading branch information
joeldenning committed Apr 9, 2019
1 parent 1174056 commit 0cd7322
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 19 deletions.
27 changes: 10 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,11 @@ const reactLifecycles = singleSpaReact({
React,
ReactDOM,
rootComponent,
domElementGetter: () => document.getElementById('main-content'),
});
);

export const bootstrap = [
reactLifecycles.bootstrap,
];

export const mount = [
reactLifecycles.mount,
];

export const unmount = [
reactLifecycles.unmount,
];
export const bootstrap = reactLifecycles.bootstrap;
export const mount = reactLifecycles.mount;
export const unmount = reactLifecycles.unmount;
```
## Options
Expand All @@ -50,10 +41,12 @@ All options are passed to single-spa-react via the `opts` parameter when calling
- `loadRootComponent`: (optional) A loading function that returns a promise that resolves with the parcel. This takes the place of the `rootComponent` opt, when provided. It is intended to help people
who want to lazy load the source code for their root component. The source code will be lazy loaded during the bootstrap lifecycle.
- `suppressComponentDidCatchWarning`: (optional) A boolean that indicates if single-spa-react should warn when the rootComponent does not implement componentDidCatch. Defaults to false.
- `domElementGetter`: (optional) A function that takes in no arguments and returns a DOMElement. This dom element is where the React application will be bootstrapped, mounted, and unmounted.
Note that this opt can only be omitted when domElementGetter is passed in as a [custom prop](https://github.com/CanopyTax/single-spa/blob/master/docs/applications.md#custom-props) or if `domElement`
is passed as prop. So you must either do `singleSpaReact({..., domElementGetter: function() {return ...}})`, `singleSpa.registerApplication(name, app, activityFn, {domElementGetter: function() {...}})`,
or `singleSpaReact({..., domElement})`.
- `domElementGetter`: (optional) A function that takes in no arguments and returns a DOMElement. This dom element is where the
React application will be bootstrapped, mounted, and unmounted. Note that this opt can be omitted. When omitted, the `domElementGetter` or `domElement`
[custom single-spa props](https://github.com/CanopyTax/single-spa/blob/master/docs/applications.md#custom-props) are used.
To use those, do `singleSpa.registerApplication(name, app, activityFn, {domElementGetter: function() {...}})` or
`singleSpa.registerApplication(name, app, activityFn, {domElement: document.getElementById(...)})`. If no dom element can be found through any
of those methods, then a container div will be created and appended to document.body, by default.
- `parcelCanUpdate`: (optional) A boolean that controls whether an update lifecycle will be created for the returned parcel. Note that option does not impact single-spa applications, but only parcels.
It is true by default.
- `renderType`: (optional) ENUM of one of the following: [ 'render', 'hydrate', 'createRoot' ]. Defaults to `'render'`. Allows you to choose which ReactDOM render method you want to use for your application.
Expand Down
3 changes: 1 addition & 2 deletions src/single-spa-react.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,10 @@ const defaultOpts = {
ReactDOM: null,
rootComponent: null,
loadRootComponent: null,
domElementGetter: null,
suppressComponentDidCatchWarning: false,

// optional opts
domElementGetter: null, // only can be omitted if provided as a custom prop
domElementGetter: null,
parcelCanUpdate: true, // by default, allow parcels created with single-spa-react to be updated
}

Expand Down

0 comments on commit 0cd7322

Please sign in to comment.