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

Update PropTypes to support single axis scale values #2537

Closed
wants to merge 3 commits into from
Closed

Conversation

scottqmn
Copy link

Related issue #2489

Users would get PropType errors on scale props when single axis values were provided (e.g. scale={{ x: 'log' }}) even though documentation and demos both have examples of single axis scale props and the components functioned normally.

PropTypes for scale have been updated to no longer require both axises. PropTypes.shape was replaced with PropTypes.exact in order to catch invalid properties (e.g. { z: 'log' })

Caveat

TypeScript error is suppressed on updated prop types. The error appears when isRequired is removed from either axis properties. A verbose workaround could be to list each possible combination of axis properties to keep isRequired like so:

scale: PropTypes.oneOfType([
  CustomPropTypes.scale,
  PropTypes.exact({
    x: CustomPropTypes.scale.isRequired,
    y: CustomPropTypes.scale.isRequired,
  }),
  PropTypes.exact({
    x: CustomPropTypes.scale.isRequired,
  }),
  PropTypes.exact({
    y: CustomPropTypes.scale.isRequired,
  }),
])

@changeset-bot
Copy link

changeset-bot bot commented Dec 15, 2022

⚠️ No Changeset found

Latest commit: ce91cf6

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@andymerskin
Copy link

Hey there! Any momentum on this? I'd very much like to stop seeing the console error for this 😁

Thanks for getting this started!

@carbonrobot
Copy link
Contributor

We will be removing all prop-types in the next major release and focusing on full TS support.

@carbonrobot carbonrobot closed this Jan 8, 2024
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.

None yet

3 participants