Workiva / Workiva/over_react

cannot return null from connected component

Open
#446 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Dart
Stars
432
Forks
57
PR merge metrics
No merged PRs in 30d

Description

  • 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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing the connected-component handling of mapStateToProps and reproduce the null return described in the issue. Check how the returned value reaches the map conversion that raises the TypeError. Done means a connected component can return null from mapStateToProps without throwing and the behavior is covered by a regression test.

Written by the indexing model from the issue text.

Assessment

Tech stack
dart
Domain
frontend, web-dev
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.