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

Possible fix for counter-bar props error #42

Merged
merged 3 commits into from
Jul 27, 2018
Merged

Conversation

gavinorland
Copy link
Collaborator

#39

@gavinorland gavinorland requested review from stevesims and Loque- July 26, 2018 08:37
@codecov
Copy link

codecov bot commented Jul 26, 2018

Codecov Report

Merging #42 into master will not change coverage.
The diff coverage is 100%.

Impacted file tree graph

@@          Coverage Diff          @@
##           master    #42   +/-   ##
=====================================
  Coverage     100%   100%           
=====================================
  Files          19     19           
  Lines         146    148    +2     
  Branches       16     16           
=====================================
+ Hits          146    148    +2
Impacted Files Coverage Δ
components/counter-bar/src/index.js 100% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update da1a63f...30ba6f5. Read the comment docs.

@@ -240,7 +257,7 @@ CounterBar.Item = ({
}) => {
const Wrapper = wrapper.withComponent(component);
return (
<Wrapper active={active} disabled={!score} empty={ !children || children.length === 0 ? 1 : 0 } {...props}>
<Wrapper active={active ? 1 : 0} disabled={!score} empty={ !children || children.length === 0 ? 1 : 0 } {...props}>
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this fix is wrong - as is the use of a pseudo-boolean for empty here too - it's a bodge that avoids addressing the underling issue and will instead potentially create other issues with other components we may be using through the component prop

the underlying issue here is that we're using emotion to style and emotion by default will pass through props that should be used for styling only on to the underlying component.

what we should be doing is explicitly ensuring that we do not pass through props that we're using for styling.

emotion includes support for providing an option shouldForwardProp - a function to indicate whether a prop should be forwarded or not which accepts the prop name as a string. some info on this can be found here: emotion-js/emotion#655

for our purposes on the TotalWrapper i believe we'd need something like:

shouldForwardProp: prop => ['active', 'empty'].indexOf(prop) === -1

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see what you mean, Steve, they're unnecessarily being passed on. Will take another look at this on train.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice one - this issue is a PITA, nice fix!

@gavinorland gavinorland merged commit 0938d2d into master Jul 27, 2018
@gavinorland gavinorland deleted the fix/counterbar-active branch July 27, 2018 14:40
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.

3 participants