Skip to content

Conversation

robbieculkin
Copy link
Contributor

@robbieculkin robbieculkin commented Jul 28, 2025

Reasons for making this change

Addresses #4690.

React's default Component rendering strategy is to re-render on every state change, see shouldComponentUpdate docs. PureComponent's strategy uses shallow equality.

This PR allows users to select the shouldRender React behavior to be used via a new prop, experimental_componentUpdateStrategy. There are 3 options:

  • customDeep (default): uses RJSF's deepEquals
  • shallow: shallow equality
  • always: returns true. component always rerenders.

Checklist

  • I'm updating documentation
  • I'm adding or updating code
    • I've added and/or updated tests. I've run npx nx run-many --target=build --exclude=@rjsf/docs && npm run test:update to update snapshots, if needed.
    • I've updated docs if needed
    • I've updated the changelog with a description of the PR
  • I'm adding a new feature
    • I've updated the playground with an example use of the feature

@robbieculkin robbieculkin marked this pull request as draft July 28, 2025 22:38
@robbieculkin robbieculkin changed the title works Option to use default React shouldComponentUpdate logic Jul 28, 2025
@robbieculkin robbieculkin marked this pull request as ready for review July 28, 2025 23:27
@robbieculkin robbieculkin changed the title Option to use default React shouldComponentUpdate logic Options to use default React shouldComponentUpdate logic Jul 29, 2025
const { experimental_componentUpdateStrategy = 'customDeep' } = this.props.registry;

return shouldRender(this, nextProps, this.state, experimental_componentUpdateStrategy);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I hadn't realized that this behavior also applied to SchemaField. Nice catch!

@nickgros nickgros merged commit 7709436 into rjsf-team:main Aug 1, 2025
4 checks passed
@robbieculkin
Copy link
Contributor Author

robbieculkin commented Aug 11, 2025

@heath-freenome, @nickgros, or another maintainer -- would you mind helping me release this change to npm? I'm looking at the contribution guide and it's not clear to me whether this is a prerelease, custom, or other version given the -beta.13 suffix.

I've created a release MR here: #4714

@heath-freenome
Copy link
Member

@robbieculkin beta.13 is released

@robbieculkin
Copy link
Contributor Author

@heath-freenome thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants