over_react
over_react copied to clipboard
cannot return null from connected component
- Issue Type: [BUG, FEATURE REQUEST, etc.]
over_reactVersion(s):3.1.7
I expected that since it is legal to return null from the render() method of a normal React component, that it would be legal to return null from the mapStateToProps function. I realize they have different return types, but it seems the meaning should be the same in each case (i.e., don't render anything).
However, it generates this error:
dart_sdk.js:15575 Uncaught TypeError: Cannot read property 'Symbol(dartx.keys)' of null
at js_backed_map.JsBackedMap.new.addAll (dart_sdk.js:15575)
at js_backed_map.JsBackedMap.new.addAll (js_backed_map.dart:95)
at Function.from (js_backed_map.dart:34)
at Object.jsBackingMapOrJsCopy (js_backed_map.dart:151)
...
The workaround is to render the unconnected version of the component, but pass it a special prop that means "return null immediately".
But the intent would be communicated more straightforwardly if the mapStateToProps function could return null on its own.
FYI: @greglittlefield-wf @aaronlademann-wf @kealjones-wk @evanweible-wf @maxwellpeterson-wf