over_react icon indicating copy to clipboard operation
over_react copied to clipboard

cannot return null from connected component

Open dave-doty opened this issue 6 years ago • 0 comments

  • Issue Type: [BUG, FEATURE REQUEST, etc.]
  • over_react Version(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

dave-doty avatar Dec 22 '19 19:12 dave-doty