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.

Does not apply propTypes using `$Exact<>`

See original GitHub issue

I am using $Exact<> to ensure that only certain props are passed to a component (flow will fail if any others are passed). I understand that checking for extraneous props is not easily handled with propTypes, but all type definitions wrapped in $Exact<> are ignored.

This works:


type ComponentProps = {
    someProp: string,
};

This does write any propType checks:

type ComponentProps = $Exact<{
    someProp: string,
}>;

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

0reactions
gabrocommented, Oct 1, 2016

See also https://github.com/facebook/flow/pull/2525 for the WIP documentation 😉

Read more comments on GitHub >

github_iconTop Results From Across the Web

Difference between PropTypes.exact and PropTypes.shape
1 Answer 1 · What happens with missing properties? · Both will give you warning i.e if you do not pass color for...
Read more >
Typechecking With PropTypes - React
To run typechecking on the props for a component, you can assign the special propTypes property:
Read more >
How to validate React props using PropTypes - LogRocket Blog
Learn how to validate props with React PropTypes, React's internal mechanism for adding type checking to component props.
Read more >
prop-types-exact - npm
For use with React PropTypes. Will error on any prop not explicitly specified.. Latest version: 1.2.0, last published: 5 years ago.
Read more >
How To Use PropTypes In React - Web Dev Simplified Blog
If you did want to throw a warning, though, when the object has properties not specified in the PropTypes you could use PropTypes.exact() ......
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