Skip to content

Commit 2248dcc

Browse files
committed
add renderUnitialized option
1 parent ad0114e commit 2248dcc

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,9 @@ re-mounting the component with a clean loader state.
200200
* __`pureConnect`__ _(Bool)_: This library uses `connect()` from `react-redux` under hood. Set `pureConnect: false` if you wish to prevent `connect()` from controlling component updates based on props.
201201
- default: `true`
202202

203+
* __`renderUninitialized`__ _(Bool)_: Render wrapped component when the loader state has not yet been initialized.
204+
- default: `false`
205+
203206
### mapStateToProps
204207

205208
`mapStateToProps` is an optional function to provide if you want to

src/reduxAutoloader.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ export default function reduxAutoloader({
4343
reinitialize = () => false,
4444
reload = () => false,
4545
pureConnect = true,
46+
renderUninitialized = false,
4647
/* eslint-enable react/prop-types */
4748
}, mapStateToProps = state => state) {
4849
assert(name, 'name is required');
@@ -265,13 +266,11 @@ export default function reduxAutoloader({
265266
}
266267

267268
render() {
268-
if (!this.props.hasBeenInitialized) {
269-
return null;
269+
if (this.props.hasBeenInitialized || renderUninitialized) {
270+
return <WrappedComponent {...this.getMappedProps(this.props)} />;
270271
}
271272

272-
return (
273-
<WrappedComponent {...this.getMappedProps(this.props)} />
274-
);
273+
return null;
275274
}
276275
}
277276

0 commit comments

Comments
 (0)