dillon1000/react

Commit

Fix slow performance of PropTypes.oneOfType() on misses (#7510)

It used to be slow whenever a type miss occurred because expensive `Error` objects were being created. For example, with `oneOfType([number, data])`, passing a date would create an `Error` object in `number` typechecker for every item.

The savings depend on how much commonly you used `oneOfType()`, and how often it had “misses”. If you used it heavily, you might see 1.5x to 2x performance improvements in `__DEV__` after this fix.
Browse files
Changed paths2 files
First-parent comparison
M src/isomorphic/classic/types/ReactPropTypes.js ModifiedM src/isomorphic/classic/types/__tests__/ReactPropTypes-test.js Modified
Patch

Files changed

Rendering syntax-highlighted changes…