[WIP] Backward compatibility for the query prop #123
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Tracking issue: #121.
This is a work in progress.
Todo:
query
, as well asqueries
queries
#119, 👋 @tstirrat15)Motivation
As per the comment in #119, this allows the use of both the
query
, as well as thequeries
prop.The
queries
prop was introduced in #72, and first discussed in #69. It's been available in thenext
branch for a while now, and after giving it some thought, I think there is significant value in keeping thequery
prop in a backward-compatible manner:next
under a minor version bump. The current changes include a bugfix for SSR, so it would be nice for people to be able to get these change in a minor version increment.<Media query=...>
occurences to<Media queries=...>
. I can imagine this would be sufficiently painful for larger codebases that it will deter people from upgrading.Discussion
Allowing both
query
as well asqueries
does add some complexity to both the implementation and the API. I'm not too worried about the implementation, but for the API it means that ideally, we would require eitherquery
orqueries
to be defined.I've currently implemented this constraint manually, but I suppose this could be done in a bit of a cleaner manner using PropTypes. If anyone knows how to implement such a constraint properly, do let me know 🤓 (@tstirrat15 ?). Quick note, I'm aware of airbnb-prop-types, and think we'd probably need something like this. I'm just not comfortable with including that lib as a dependency here, it feels a bit overkill.
Next steps
My motivation of shipping all of the current changes under a minor version are described above. What I'd really like to do is to implement a v2 based off of hooks. In this v2, I'd suggest we implement the business logic with hooks, and additionally expose the old component API (
<Media>
) which would then use the hooks internally. The only actual reason for making such an update a major version bump would be because us using hooks would require consumers to ensure they have a version of React installed that ships with hooks. Read: we'd bump the React peerDependency.