-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
BootstrapMixin solution for ES6 Classes #646
Comments
My 2 cents, I think the cleanest way to do this is to add a class decorator that attaches the additional props types. Something like: @BootstrapProps
class Label extends React.Component { ... } The syntax is a little bit unfamiliar because decorators are fairly new, but hopefully with time it will look normal/acceptable. |
That said, there's nothing wrong with ES5 classes + mixins. Facebook still use that approach internally, per the comment on: https://www.codementor.io/ama/questions/4965867003/how-soon-after-a-react-update-does-facebook-update-their-react-dependent-projects |
The decorator still does not address the concern about the |
I also don't see any issues with using existing
It is an official API for near future. When Facebook (and community as a whole) finds new I made a research about current - ideas - instead of mixins. They all have cons and pros and no one of them completely solves the issue with mixins with ES6 classes. My vision of it:
In addition:
What is the real benefit by using only and everywhere ES6 classes It has to be heavy enough benefit to overweight all those points 😉 I propose to remove |
While conversation about ES6 classes can be debated, the point that's getting missed is with regards to my original comment:
The This discussion should not be about whether ES6 Classes or Mixin use is better, it is about enabling either for most components and fixing issues with our current Mixin that's prohibiting such. On a personal note I'd like to try and use ES6 classes wherever possible since it's clear that at some point, when it makes sense to Facebook, that will be the supported approach. So changing now will help future proof us with React's changes. |
It seems today is not my day and I am very unfocused 😞 Of course I agree to try to simplify |
just for ref: the current state of
again:
... many others issues with pretty same content.
|
At least from now on we can try to use decorators Disclaimer from author:
|
We're not actually using all the Babel optional transforms: https://github.com/react-bootstrap/react-bootstrap/blob/e1c6aa227c654dbc7a3db8e4e010dca9d6e22daa/.babelrc |
I'm fine with using more if we need to, but some of them may have stability issues which we should be aware of. I used the one optional feature that the jsx tool from facebook was supporting and we needed to do the initial ES6 transformation. |
I make mention of it because of
As for the
I also would prefer not to use any of ES7 (let alone |
it seems as if a year has passed since 😄 Because since v0.24 we use "stage": 1 Update |
404? |
Pff.. a couple of days ago it was existed. 😓 There is the https://github.com/babel/eslint-plugin-babel another promising one. |
I'm on it. Will push a PR after |
We should decide what a way to choose. Now the default way to set CSS class for each component is through private API It was always possible to set this property to any custom value and I'm afraid that there could exist some code that use it, though I presume those are edge cases and they do it wrong. Now we have If we decide that we allow users to set their own custom classes for our components, Though: I believe this is the wrong way. Users should use
|
I'm not sure we should remove those new props until there is a better solution for BootstrapMixin, as of right now it is really functioning as a private prop as far as I can tell, whereas the As it is now there is no way that |
One potential use case of a custom bsClass was proposed in #404, where someone wanted to essential style a modal as an aside. The DOM structure was identical the only difference is the class prefix. |
Ok then. At this stage we agree:
While I'm eliminating this Mixin, I see, that we can totally remove |
I think my previous comment pointed at the contrary, |
I think it makes sense as a public api, but we really need to clean it up before I feel comfortable really telling ppl about it, since it works oddly right now. For all intents and purposes it is a prop and so a technically a public api, whether we want it to be or not, so we need to treat it as a breaking change if we change the behavior. At to the earlier discussion if we are adding an api to add custom bsClasses then it really needs to be public ultimately, right? |
which is all to say: some places we treat it like its private and others we don't |
I have no problem at all with Should we at some future point, when |
I had to change the |
No worries. I deal with it after the |
#1257 is successor of this. |
Seeing as mixins are not supported with ES6 classes, we need to figure out a different way to handle what's going on in the
BootstrapMixin
.As much as I love that I don't need to declare the three PropTypes
bsClass
,bsStyle
, andbsSize
they are not a good one size fits all solution. For example theButton
component does not have css defined fortabs
orpills
which this implementation will allow. However, the current solution allows you to easy impose your own custom rules into the validation check; see #306, #440, and #496. @trevorr has done a great job with this so far and I'd still like to be able to support something like this, though I imagine it will get more complicated.The current
getBsClassSet
function shouldn't be too diffucult to extract to a purely static function without any dependency onthis
so I'm not too concerned with that.This is an issue that needs to be figured out sooner rather than later to continue allowing us to use ES6 Classes. (For example lack of support for this is blocking suggestions such as those proposed in #626 (comment))
The text was updated successfully, but these errors were encountered: