Feature Request: Is there any possible to read other props in a specific validator function?
See original GitHub issueAs above, I want to validate a props
data propA
in the validator
function and I want to read the props
data propB
so that I can judge whether they are valid together.
Issue Analytics
- State:
- Created 7 years ago
- Reactions:17
- Comments:9 (8 by maintainers)
Top Results From Across the Web
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 >How to apply validation on Props in ReactJS ? - GeeksforGeeks
React JS has an inbuilt feature for validating props data type to make sure that values passed through props are valid. React components...
Read more >React eslint error missing in props validation - Stack Overflow
It can not correctly detect what props were mentioned in propTypes if you have annotated named objects via destructuring anywhere in the class....
Read more >Typechecking With PropTypes - React
For some applications, you can use JavaScript extensions like Flow or TypeScript to typecheck your whole application. But even if you don't use...
Read more >How To Customize React Components with Props
Props are the arguments you pass to a function or class, but since your components are transformed into HTML-like objects with JSX, you...
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 FreeTop 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
Top GitHub Comments
@JounQin As @LinusBorg has said, the feature for prop validation depending on other props is too complex, error-prone (needs correct prop initialization order), not commonly needed, and cannot solve the problem of interdependent validation (propA requires propB, propB require propA). On the other hand, it’s already easy enough to be implemented with computed properties. So in my opinion this feature shouldn’t be included in vue since it’s too user-specific.
Therefore my recommendations remain to be a). use computed properties. b). use a mixin to check inside hooks.
@fnlctrl your solution is just like validating them together on the
created()
hook, but I think we should do the validation in a proper place rather than mixing it in our business logic.