Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Boolean props that default to undefined can’t be explicitly set to false #95

Open
kapowaz opened this issue Mar 23, 2023 · 0 comments

Comments

@kapowaz
Copy link

kapowaz commented Mar 23, 2023

Let’s say I have a component which accepts an optional Boolean prop:

export const MyComponent = ({ shouldDoSomething = undefined }: { shouldDoSomething?: boolean; }) => {
  return (<div>{shouldDoSomething ? 'should do the thing!' : 'should not do the thing'}</div>;
}

If I set up an example for this using react-view, I can’t ever set shouldDoSomething to false, with this configuration:

const propConfig = {
  shouldDoTheThing: {
    type: PropTypes.Boolean,
    description:
      'Should do the thing or not?',
    value: true,
  }
};

If I configure my component example to explicitly set shouldDoTheThing to false, react-view simply omits that prop from the code editor example (and in React Dev Tools you can see the prop is missing; setting it explicitly there works).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant