From 4aeb4716013d430d9f6f658aa0ac3bdf04a16684 Mon Sep 17 00:00:00 2001 From: Alexander Date: Thu, 12 Nov 2020 17:32:31 -0800 Subject: [PATCH] Omit null state and props to fix default props --- lib/withOnyx.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/withOnyx.js b/lib/withOnyx.js index 23d61ed82..af8598ba5 100644 --- a/lib/withOnyx.js +++ b/lib/withOnyx.js @@ -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 (