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

Add boolean decorator which defaults to true #22

Closed
gtnx opened this issue Sep 27, 2018 · 1 comment
Closed

Add boolean decorator which defaults to true #22

gtnx opened this issue Sep 27, 2018 · 1 comment

Comments

@gtnx
Copy link

gtnx commented Sep 27, 2018

With current boolean implementation, default value is false. It'd be nice to control this.

@davidbonnet
Copy link
Member

Defaulting a boolean to false is a natural default, akin [] for an array, {} for an object, and so on.

Realue’s decorator design guideline is to be modular and to set behavior from props as much as possible.

Should there be a different default value wanted, the defaultValue decorator can fulfill that:

const BooleanComponent = compose(
  defaultValue,
  boolean,
)(({ value }) => <span>{value ? 'True' : 'False'}</span>)

// Sets `defaultValue` to `true` and renders <span>True</span>
<BooleanComponent defaultValue />

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

2 participants