getDerivedStateFromError is able to return null in if the state should not change at all but currently this is unsupported in react-dart. Additionally if the lifecycle is not implemented but is not specified in skipMethods when it runs it will throw the following error (error is from an OverReact component but applies to react-dart):
Uncaught TypeError: Cannot read property 'Symbol(dartx.keys)' of null
at js_backed_map.JsBackedMap.new.addAll (dart_sdk.js:15563)
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)
at react_client.dart:637
at _RootZone.run (dart_sdk.js:32144)
at handleGetDerivedStateFromError (react_client.dart:631)
at Object._checkAndCall (dart_sdk.js:4074)
at Object.dcall (dart_sdk.js:4079)
at Object.ret [as handleGetDerivedStateFromError] (dart_sdk.js:52079)
at getDerivedStateFromError (_dart_helpers.js:130)
at ReactDartComponent2.update.payload (react-dom.development.js:3814)
at getStateFromUpdate (react-dom.development.js:2505)
at processUpdateQueue (react-dom.development.js:2525)
at updateClassInstance (react-dom.development.js:2602)
at updateClassComponent (react-dom.development.js:3064)
at beginWork$1 (react-dom.development.js:3432)
at HTMLUnknownElement.callCallback (react-dom.development.js:127)
at Object.invokeGuardedCallbackDev (react-dom.development.js:147)
at invokeGuardedCallback (react-dom.development.js:162)
at beginWork$$1 (react-dom.development.js:4377)
at performUnitOfWork (react-dom.development.js:4183)
at workLoopSync (react-dom.development.js:4179)
at performSyncWorkOnRoot (react-dom.development.js:4115)
at react-dom.development.js:2256
at unstable_runWithPriority (scheduler.development.js:818)
at runWithPriority$2 (react-dom.development.js:2250)
at flushSyncCallbackQueueImpl (react-dom.development.js:2256)
at flushSyncCallbackQueue (react-dom.development.js:2255)
at scheduleUpdateOnFiber (react-dom.development.js:3965)
at Object.enqueueSetState (react-dom.development.js:2565)
at ReactDartComponent2../node_modules/react/cjs/react.development.js.Component.setState (react.development.js:325)
at UiComponent2BridgeImpl.setState (bridge.dart:85)
at shell._$ShellComponent.new.setState (react.dart:641)
at batched_redraws.dart:41
at LinkedMap.new.forEach (dart_sdk.js:19611)
at batched_redraws._RedrawScheduler.new._tick (batched_redraws.dart:25)
at _tick.next (<anonymous>)
at onValue (dart_sdk.js:32262)
at _RootZone.runUnary (dart_sdk.js:32148)
at _FutureListener.thenAwait.handleValue (dart_sdk.js:27863)
at handleValueCallback (dart_sdk.js:28365)
at Function._propagateToListeners (dart_sdk.js:28397)
at _Future.new.[_complete] (dart_sdk.js:28249)
at _SyncCompleter.new.complete (dart_sdk.js:27793)
at dart_sdk.js:94639
Changes
Update getDerivedStateFromError handler methods to store return value into a variable and check it for null before processing.
Motivation
getDerivedStateFromError
is able to returnnull
in if the state should not change at all but currently this is unsupported in react-dart. Additionally if the lifecycle is not implemented but is not specified inskipMethods
when it runs it will throw the following error (error is from an OverReact component but applies to react-dart):Changes
getDerivedStateFromError
handler methods to store return value into a variable and check it for null before processing.