Skip to content

Conversation

@cjskillingstad
Copy link
Contributor

Description

  • Mark props as required that are required for functionality
  • Set default props
    • I didn't set default strings as '', funcs as () => {}, numbers as null, objects as {}, etc. as it seemed somewhat unnecessary. I did do the bools as false because I think it will make the documentation more readable. Let me know if you think I should do those other cases.
  • Update snapshots where necessary

fixes #244

@cjskillingstad cjskillingstad requested a review from a team January 29, 2019 22:17
@bcullman
Copy link
Contributor

there are a number of props that moved to required here - it would be good to kick out a new release to get updated docs to go along with this PR.

children: PropTypes.node,
className: PropTypes.string,
type: PropTypes.oneOf(['', 'error', 'warning', 'help'])
type: PropTypes.oneOf(['error', 'warning', 'help'])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mobot11 : looks like this was missed in the earlier const PR

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should either fix this or create a follow-up issue.

Copy link
Contributor

@jbadan jbadan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🚢

@bcullman
Copy link
Contributor

really nice cleanup here, @cjskillingstad!

children: PropTypes.node,
className: PropTypes.string,
type: PropTypes.oneOf(['', 'error', 'warning', 'help'])
type: PropTypes.oneOf(['error', 'warning', 'help'])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should either fix this or create a follow-up issue.

// check to make sure itemsPerPage != 0
this.numberOfPages = Math.ceil(
itemsTotal / (itemsPerPage ? itemsPerPage : 10)
itemsTotal / (itemsPerPage || 10)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With a default value, we could remove the || 10.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought about this, but if the consumer passes in a 0 then this will break

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair enough. If it would break with certain values, then we should consider adding a custom prop type validator that would prevent that. But, that would be a follow-up enhancement if we wanted to do that.

@cjskillingstad
Copy link
Contributor Author

@mobot11 @greg-a-smith Using const's for the last couple places we missed in the propTypes in e09cb71

Copy link
Contributor

@greg-a-smith greg-a-smith left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. 🚢 Lots of work, but worth it in the long run!

@cjskillingstad cjskillingstad merged commit 128bffd into master Jan 31, 2019
@cjskillingstad cjskillingstad deleted the fix/required-default-props branch January 31, 2019 21:49
greg-a-smith pushed a commit that referenced this pull request Mar 5, 2019
* ActionBar

* Alert

* Button

* Calendar

* DatePicker

* Dropdown

* FormRadio

* InputGroup

* LocalizationEditor

* Menu

* Modal

* MultiInput

* Pagination

* SearchInput

* Shellbar

* SideNavigation

* Table

* Tabs

* Tile

* Tile

* Time

* TimePicker

* Toggle

* Remove false default props

* Make description optional

* Add default prop for funcs

* Default prop consts

* Remove static proptypes

* Remove last false default prop
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

Successfully merging this pull request may close these issues.

Mark appropriate props as required and use default props

5 participants