RXNT/react-jsonschema-form-conditionals

/src/index.js, function: componentWillReceiveProps

zboldyga opened this issue · 3 comments

React documentation mentions that in componentWillReceiveProps, it might make sense to check if props have changed before re-setting the state, since the function is potentially called with identical props. It shows how to make the check.

https://facebook.github.io/react/docs/react-component.html#componentwillreceiveprops

On another note, same function - I see why you've called ruleTracker from the onChange handler. It seems like a valid way to track whether the Mozilla Form has changed state (and it's own props), and they seem to specifically outline this in their documentation. e.g.

'WARNING: If you have situations where your parent component can re-render, make sure you listen to the onChange event and update the data you pass to the formData attribute.'

I'm fairly new to React, but it seems like the React documentation tries to encourage us to handle these types of updates from the built-in pre-render handlers. Interested to hear ur thoughts.

I've optimized rendering by playing with shouldComponentUpdate, which is triggered in 3 cases

  1. Schema changed
  2. uiSchema changed
  3. external properties changed

The only drawback I see with this is that currently all actions are limited to schema and uiSchema and we should be extra careful if we decide to extend this beyond this scope