GithubHelp home page GithubHelp logo

Comments (11)

ljharb avatar ljharb commented on July 30, 2024 1

Because we didn’t have a use case for anything but the complete check.

What’s your use case?

from prop-types.

ljharb avatar ljharb commented on July 30, 2024 1

Can you use childrenOf(withShape(PropTypes.element, { stepName: string.isRequired })).isRequired?

from prop-types.

Asday avatar Asday commented on July 30, 2024 1

Well gosh I think that's that then.

I feel like this issue kinda took a walk away from what I was originally askin', 'cause I was asking the wrong thing. I still think it's appropriate to close though, as my issue has been solved, so I bid you adieu, and thanks.

from prop-types.

ljharb avatar ljharb commented on July 30, 2024 1

Closing pending confirmation.

from prop-types.

Asday avatar Asday commented on July 30, 2024

Might be silly? Hopefully you'll be able to tell me.

Writing a <Wizard /> that expects to be passed children with a unique (to the wizard) stepName prop. Currently my thinking is and([childrenHaveProp('stepName'), childrenPropsAreUnique('stepName')]) or something similar would be elegant.

from prop-types.

ljharb avatar ljharb commented on July 30, 2024

so <div stepName="not a real step" /> would be valid?

from prop-types.

Asday avatar Asday commented on July 30, 2024

I don't see why not. That sort of functionality would be useful for showing an interstitial page like YouGov's "on to a different topic..." pages in their surveys.

from prop-types.

Asday avatar Asday commented on July 30, 2024

Ooh, that looks very promising. So that's essentially the childrenHaveProp() in my conjectural example I think?

Is the .isRequired on childrenOf() making it so at least one is required?

from prop-types.

ljharb avatar ljharb commented on July 30, 2024

yep, exactly.

from prop-types.

Asday avatar Asday commented on July 30, 2024

Sorry, I'm back - that doesn't appear to work. As a cut down example:

class Wizard extends Component {
  static propTypes = {
    children: childrenOf(withShape(
      PropTypes.element,
      { stepName: PropTypes.string.isRequired },
    )).isRequired,
  }

  render = () => null
}

<Wizard><Text stepName="First">First</Text><Text stepName="Last">Last</Text></Wizard> raises Warning: Failed prop type: The prop stepNameis marked as required inWizard, but its value is undefined``. Dropping the stepName prop from either or both of the children results in the same message.

It looks like prop-types (facebook's, not yours) is checking for stepName on <Wizard /> rather than its children, but I'm not smart enough to figure out if that's true, and/or why.

I've renamed the issue to make more sense given the direction it took.

from prop-types.

ljharb avatar ljharb commented on July 30, 2024

@Asday with the latest version of prop-types (facebook's), is this still an issue?

from prop-types.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.