react.dart
react.dart copied to clipboard
components lose properties
In https://github.com/danschultz/react.dart/blob/master/lib/src/react/factory.dart#L58 the properties are removed. This causes failure when state is updated and the component tries to render but has no properties.
Was this a copy pasta error or is there something I'm missing?
I removed it locally and it fixes the problem for me. I'll PR if you confirm
Was this a copy pasta error or is there something I'm missing?
No, this was just a scenario that wasn't fully thought out. This line prevents a memory leak by removing the props that are needed for the lifecycle js-interop calls when a component is rendered.
A proper fix would be to have componentWillUpdate
store the "previous props" somewhere, so that it's available in componentDidUpdate
. One approach is to introduce a new Component._update(props, state)
method that's called from componentWillUpdate
, This would set Component._props
, Component._state
, and a new Component._prevProps
field. Then you could access Component._prevProps
from componentDidUpdate
.
Unfortunately, my innovation week has ended so I'll drop this for a while.
I am making do with the workaround https://github.com/Andersmholmgren/react.dart/tree/workaround_for_missing_props for now