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
Feature request: Be able to control the class load order when merging classNames #165
Comments
Sounds like this would fit into an enhancer perfectly. Yet I guess we have to rewrite the |
I will release some new tools and guides on how to actually compose rules / components with Fela, which makes it obsolete to use any of the above requested addons. Teaser: All it uses is combineRules and it works great :) |
Great, just came back from holiday and wanted to ask if PRs are welcome. |
Any thoughts and ideas are still welcome. But please share on Gitter before spending a lot of time implementing stuff that might not be added at all, hehe :P I am curious on your ideas though |
With the next release, I got you covered. Locally, |
Thanks for solving this request @rofrischmann ! I could not find the right commit to preview the upcoming API (and logic) behind the solution. Could you be so kind and mention the code/commit/doc? |
I guess it's all here: Documentation is coming soon. (tomorrow hopefully) |
Great, thanks a lot! (btw. slick solution) |
Version: 4.1.1
Environment: Both
Type: Feature
Description
When fela is used in context of react, the lazy evaluation results in styles getting appended to
stylesheet
in an arbitrary order. Ifclassname
is inherited from a parent and merged within the child component (className={'${this.props.className} ${baseClassName}'}
) there is no predictable way to tell which className wins.As a result the rendered result can diverge based on component load order and is hardly testable.
More details here (Non-deterministic Resolution)
Current solutions
Problems:
shouldComponentUpdate
(shallowCompare(this.props.style, nextProps.style)
)style
andclassName
in parallelProblems:
flex: 1 1 auto
, a parent must useflexGrow: 0
Problems:
Without going into the details: it's ugly, it's a workaround, it's a sword of Damocles.
Goals
A child's API should stay consistent to DOM elements.
If you pass
style
, you expect that (merged or replaced)style
on the child, if you passclassName
you expect (merged or replaced)className
on the child.You never need to expect some black magic where
style
becomesclassName
Proposal
simple POC
It caches
className
and it's correspondingpropType
e.g.{a: 'flex', b: 'width, c: 'width' }
It can then be used like
The text was updated successfully, but these errors were encountered: