question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Huge performance penalty because of immutable props validation

See original GitHub issue

NODE_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:closed
  • Created 7 years ago
  • Comments:9 (1 by maintainers)

github_iconTop GitHub Comments

3reactions
dounancommented, Oct 10, 2016

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.

0reactions
sergiu-paraschivcommented, Oct 7, 2016

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found