Huge performance penalty because of immutable props validation
See original GitHub issueNODE_ENV=production
disables React’s PropTypes but not ImmutablePropTypes.
After manually removing them I got a 75%(!!!) rendering speed improvement.
I’m using stuff ranging from
let somePropType = ImmutablePropTypes.mapContains({
id: PropTypes.string.isRequired,
name: PropTypes.string.isRequired,
isProjectLeader: PropTypes.bool,
isHidden: PropTypes.bool,
projectLeaderColor: PropTypes.string,
index: PropTypes.number
});
to
let listOfSomePropType = ImmutablePropTypes.listOf(somePropType).isRequired
Is there a way for me to disable validation in production?
Issue Analytics
- State:
- Created 7 years ago
- Comments:9 (1 by maintainers)
Top Results From Across the Web
Why is immutability so important (or needed) in JavaScript?
Basically it comes down to the fact that immutability increases predictability, performance (indirectly) and allows for mutation tracking. Predictability.
Read more >PropType validation errors when using custom validators
I believe the issue is related to #134. var React = require('react') , ImmutablePropTypes = require('react-immutable-proptypes'); ...
Read more >Write safe and efficient C# code
Follow this recommendation whenever your design intent is to create an immutable value type. Any performance improvements are an added benefit.
Read more >How to validate React props using PropTypes
Learn how to validate props with React PropTypes, React's internal mechanism for adding type checking to component props.
Read more >Immutability / Don't Mutate my State! > React with Symfony
First, unlike PHP, in JavaScript arrays are objects. And so, like all objects, if you modify repLogs , that also modifies this.state.repLogs because......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
What version of React are you on? Also how are you doing the profiling? Just curious how you came to the conclusion that React was actually running the validation logic. I don’t think I have seen this issue yet in my usage.
Performance penalty comes from the actual validation. When you have an Immutable List of Maps of a certain shape the validation process is at least half of re-rendering time.