Skip to content
Merged
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
8 changes: 6 additions & 2 deletions lib/withOnyx.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,13 +143,17 @@ export default function (mapOnyxToState) {

// Remove any internal state properties used by withOnyx
// that should not be passed to a wrapped component
const stateToPass = _.omit(this.state, 'loading');
let stateToPass = _.omit(this.state, 'loading');
stateToPass = _.omit(stateToPass, value => _.isNull(value));

// Remove any null values so that React replaces them with default props
const propsToPass = _.omit(this.props, value => _.isNull(value));

// Spreading props and state is necessary in an HOC where the data cannot be predicted
return (
<WrappedComponent
// eslint-disable-next-line react/jsx-props-no-spreading
{...this.props}
{...propsToPass}
// eslint-disable-next-line react/jsx-props-no-spreading
{...stateToPass}
/>
Expand Down