-
-
Notifications
You must be signed in to change notification settings - Fork 214
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
Render Component that returns null #195
Conversation
This would be a breaking change. Cannot merge this without (a) introducing a In the mean time, this does not break anything in React v0.15, therefore it is safe to leave this PR hanging until general adoptoption of the lastest React version. Thank you |
Currently Last component wrapped with CSSModules:
Last component is a pure react function
Thank you for your fast reaction |
This behaviour could be made conditional. I think. Need to think more about the implications. |
What do you think if we check React version and return |
Thats what I am thinking too. I suppose it is reasonable that developer's styling can break in this instance when updating the React version. Albeit, it is confusing since the break is being introduced by However, in this case, I think that the pros outweigh the cons. |
@gajus what do you think about such kind of fix? |
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.
You should also add tests to check different React versions
import React from 'react'; | ||
|
||
export default function () { | ||
const major = React.version.split('.')[0]; |
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.
You really need to calculate it once. And you can check if it's < 15 only once too.
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.
I'am not fully confident that cache
is 100% safe for this case. Someone might want to use different react versions with cssModules
, isn't he?
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.
you are checking version of React that you import yourself, it's not going to change on the fly
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.
Yes, you are right
1aa8dd6
to
eb40c80
Compare
@gajus any updates for this PR? |
@@ -0,0 +1,22 @@ | |||
/* eslint-disable max-nested-callbacks, react/prefer-stateless-function, class-methods-use-this */ |
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.
Whats the reason for needing react/prefer-stateless-function, class-methods-use-this
?
const major = React.version.split('.')[0]; | ||
const nothing = parseInt(major, 10) < 15 ? React.createElement('noscript') : null; | ||
|
||
export default nothing; |
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.
Please reformat this to:
import React from 'react';
export default (reactVersion) => {
const major = reactVersion.split('.')[0];
const nothing = parseInt(major, 10) < 15 ? React.createElement('noscript') : null;
};
@@ -39,6 +39,7 @@ | |||
"husky": "^0.11.9", | |||
"jsdom": "^9.8.3", | |||
"mocha": "^3.1.2", | |||
"proxyquire": "^1.7.10", |
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.
Remove proxyquire
dependency.
@@ -39,7 +39,7 @@ export default (Component: Function, defaultStyles: Object, options: Object): Fu | |||
return linkClass(renderResult, styles, options); | |||
} | |||
|
|||
return React.createElement('noscript'); | |||
return nothing; |
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.
Replace with renderNothing(React.version)
.
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.
Fixed and squashed
} from 'chai'; | ||
import proxyquire from 'proxyquire'; | ||
|
||
describe('renderNothing', () => { |
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.
Test renderNothing
as a function.
Since React 15 has been released no more
<noscript>
tag needed