Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,23 @@ const store: IModuleStore<IState> = createStore({
<div>Hello World!!</div>
</DynamicModuleLoader>
```
```typescript
export interface IDynamicModuleLoaderProps {
/** Modules that need to be dynamically registerd */
modules: IModuleTuple;

/**
* Set this flag to indicate that this component is being rendered in 'Strict Mode'
* React 'StrictMode' does not allow constructor side-effects, so we defer adding modules to componentDidMount
* when this flag is set.
* This has the effect of adding a second render.
*/
strictMode?: boolean;

/** Optional callback which returns a store instance. This would be called if no store could be loaded from th e context. */
createStore?: () => IModuleStore<any>;
}
```

## Extensions

Expand Down
18 changes: 18 additions & 0 deletions docs/reference/DynamicModuleLoader.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,21 @@ export class NewUserDialog extends React.Component {
```

When `<NewUserDialog>` is rendered, the `newUserDialog` module will be added to the store. When it is unmounted, the module will be removed from the store and the state will be cleaned up.

Note the props definion for `<DynamicModuleLoader />`:

```typescript
export interface IDynamicModuleLoaderProps {
/** Modules that need to be dynamically registerd */
modules: IModuleTuple;
/**
* Set this flag to indicate that this component is being rendered in 'Strict Mode'
* React 'StrictMode' does not allow constructor side-effects, so we defer adding modules to componentDidMount
* when this flag is set.
* This has the effect of adding a second render.
*/
strictMode?: boolean;
/** Optional callback which returns a store instance. This would be called if no store could be loaded from th e context. */
createStore?: () => IModuleStore<any>;
}
```