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.

PropTypes for Preact

See original GitHub issue

Hi. 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:closed
  • Created 6 years ago
  • Comments:13 (9 by maintainers)

github_iconTop GitHub Comments

7reactions
marvinhagemeistercommented, Nov 20, 2018

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 🎉

4reactions
ForsakenHarmonycommented, May 30, 2019

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

Read more comments on GitHub >

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

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