PropTypes for Preact
See original GitHub issueHi. I’ve realised PropTypes’s alike extensible type checker which produce nice-looking report object. Instead of PropTypes which print’s some output into console. And I want to add integration for preact. Is there any way to make it play together without patching preact itself?
It could be used like so:
const TypedProps = require('typed-props');
const userShape = TypedProps.shape({
username: TypedProps.string.isRequired,
age: TypedProps.number,
});
TypedProps.check({}, userShape); // -> returns array of issues: {path:string[], rule:string, params:{}}
Thanks for any advise.
P.S. Here it is.
Issue Analytics
- State:
- Created 6 years ago
- Comments:13 (9 by maintainers)
Top Results From Across the Web
does preact have something similar to react proptypes?
PropTypes are fully supported in preact-compat, or you can use them manually. With Webpack or Browserify aliases in place, existing React ...
Read more >Differences to React - Preact
PropType Validation: Not everyone uses PropTypes, so they aren't part of Preact's core. PropTypes are fully supported in preact-compat, or you can use...
Read more >PropTypes for Preact · Issue #902 - GitHub
Hi. I've realised PropTypes's alike extensible type checker which produce nice-looking report object. Instead of PropTypes which print's some ...
Read more >PropTypes in preact - CodeSandbox
Create Sandbox Sign in. Sandbox Info. PropTypes in preact. preact-compat export PropTypes from 'prop-types' so we can import directly from 'react'.
Read more >Preact | Forem Docs
Preact supports PropTypes. When creating Preact components, please ensure that you have defined your PropTypes. Common PropTypes. Using PropTypes can be ...
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
Just an FYI: PropType checking will be possible in Preact X itself. That means that compat won’t be needed just for PropTypes anymore. Merged the PR for it yesterday 🎉
https://github.com/preactjs/preact-cli/blob/d1718255d9a81c52ad022f3308e53bdda9917bc7/packages/cli/lib/lib/entry.js#L7
You can copy what we do there though, only enable it in dev, the check gets removed in a production build because of dead code elimination