-
Notifications
You must be signed in to change notification settings - Fork 116
Change query to queries #72
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR! The changes look great, for the most part. I've made a few comments about things I'd like to address before merging.
ReactDOMServer.renderToStaticMarkup( | ||
<Media queries={queries}> | ||
{matches => { | ||
expect(matches).toMatchObject(expected) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's make the assertion on the markup instead of in the render prop and change the assertion to be something like "it renders all queries".
ReactDOMServer.renderToStaticMarkup( | ||
<Media queries={queries} defaultMatches={defaultMatches}> | ||
{matches => { | ||
expect(matches).toMatchObject(defaultMatches) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above.
modules/__tests__/Media-test.js
Outdated
ReactDOM.render( | ||
<Media queries={queries}> | ||
{matches => { | ||
expect(matches).toMatchObject(expected) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's test the output of render instead of the arguments to the render prop, just so we have complete coverage, and change the description to be something like "it renders its children function" or similar.
modules/__tests__/Media-test.js
Outdated
it('should call children with expected values', () => { | ||
ReactDOM.render( | ||
<Media queries={queries} render={matches => { | ||
expect(matches).toMatchObject(expected) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above.
modules/__tests__/Media-test.js
Outdated
ReactDOM.render( | ||
<Media queries={queries}> | ||
{matches => { | ||
expect(matches).toMatchObject(expected) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above.
modules/__tests__/Media-test.js
Outdated
it('should call children with expected values', () => { | ||
ReactDOM.render( | ||
<Media queries={queries} render={matches => { | ||
expect(matches).toMatchObject(expected) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above.
modules/__tests__/Media-test.js
Outdated
ReactDOM.render( | ||
<Media queries={queries}> | ||
{matches => { | ||
expect(matches).toMatchObject(expected) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above.
modules/__tests__/Media-test.js
Outdated
it('should call children with expected values', () => { | ||
ReactDOM.render( | ||
<Media queries={queries} render={matches => { | ||
expect(matches).toMatchObject(expected) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above.
modules/Media.js
Outdated
} | ||
|
||
render() { | ||
const { children, render } = this.props | ||
const { matches } = this.state | ||
|
||
return ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's make changes to the rendering logic in a separate PR, please. As written, this change eliminates support for non-function children
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure! I think I just didn't understand correctly what you meant in the issue comment :)
Hi @mjackson I updated the PR, but there are some alterations to the render logic, because before I tried to recreate the behavior of the render method as close as possible to the one, that is in the master branch:
The tests are also updated |
Resolved merge conflicts and prettified everything |
@gribnoysup Was this closed intentionally? |
@gribnoysup I feel like this was closed accidentally, feel free to close again if it was really closed on purpose. @mjackson do you still feel like releasing this as v2? Looking at #69 there's quite some interest in the feature! |
Hi @edorivai! I didn't see any updates for the PR after I made all the changes so I assumed that it is not needed anymore. TBH resolving conflicts with prettier changes in master was hard enough the first time, so if this PR is needed I would rather just do it from scratch |
5062135
to
634c61f
Compare
Done, the branch is updated. Hope it wouldn't go stale again 😅 |
@gribnoysup thanks a lot! I decided to merge into the @mjackson How would you want to move forward from here? Perhaps cut a v2 alpha release? |
What's the current status of this? Is it still in the works? I have a use case where lots of props on a component (in my case, a datepicker) are changed depending on which media queries match, and it would be preferable to me to have a way to have multiple queries in one rather than declaring the component multiple times inside separate components, if possible! |
A possible solution for #69
As described in this issue:
query
prop is removedqueries
prop is addedqueries
prop values are media queries (and not the prop itself)render
andchildren
props are both functions andrender
prop is an alias for children (they behave the same way)I changed tests for browser environment and also added new tests for the server environment.