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 prop types to allow for environment to be an empty object (the default) #1530

Closed
wants to merge 2 commits into from

Conversation

zmdavis
Copy link

@zmdavis zmdavis commented Aug 8, 2023

What:

Allows for the environment type to be an empty object in both the propTypes and Typescript

Why:

The default value of environment is set to an empty object ({}) during server-side rendering (or in any environment where window is undefined), but an empty object violated the shape defined for environment in prop types. This in turn triggers a console.warn.

How:

In #1525 it was suggested to remove isRequired from all properties of environment, but this had a few downsides:

  1. If environment is provided, it should be of the proper shape
  2. Typescript types and prop types would diverge unless we also updated the Typescript types (which would exacerbate the first problem)

Instead, I opted to allow for environment to be an empty object in both the propTypes and Typescript typings. However, if environment is specified (and not an empty object) it will be properly typed.

Checklist:

  • Documentation N/A
  • Tests
  • TypeScript Types
  • Flow Types
  • Ready to be merged

Fixes #1525

src/downshift.js Outdated Show resolved Hide resolved
…` can be an empty object (the default) but if provided should be a specific shape
@zmdavis zmdavis changed the title Make properties of Environment optional in prop types Update prop types to allow for environment to be an empty object (the default) Aug 8, 2023
@silviuaavram
Copy link
Collaborator

Closing this in favour of #1538. That should handle the prop type issue, along with other improvements.

@silviuaavram
Copy link
Collaborator

@all-contributors please add @zmdavis for code, bug.

@allcontributors
Copy link
Contributor

@silviuaavram

I've put up a pull request to add @zmdavis! 🎉

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.

v8: Prop type warning during server-side rendering
2 participants