We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
We need to use third party libs like clsx to complish this very common behaviour
clsx
<div className={ clsx( 'class1', condition && 'class2', condiction2 ? 'class3' : null ) } />
Use JSX to accomplish this common task directly
<div className = "class1" className = { condition && 'class2' } className = { condition2 ? 'class3' : null } /> // OR <div className={ [ 'class1', condition && 'class2', condition3 ? 'class3' : null ] } />
This should compile everything to somthing like :
React.createElement( 'div', {className: ['class1', condition && 'class2', condition2 ? 'class3' : null ] } );
The text was updated successfully, but these errors were encountered:
I propose in general to compile duplicated attributes to arrays as follow:
<div className = "c1" className = "c2" className = "c3" /> // TO React.createElement(Component, { className: [ 'c1', 'c2', 'c3' ] });
and
<div anyAttr = "value 1" anyAttr = { true } anyAttr = { callLogic() } anyAttr !anyAttr /> // TO React.createElement(Component, { anyAttr: [ "value1", true, callLogic(), true, false ] });
Sorry, something went wrong.
This is a problem that must be solved at the framework level, React is just giving you a very basic API for setting classes, that's the problem.
No branches or pull requests
Actual behaviour
We need to use third party libs like
clsx
to complish this very common behaviourWanted behaviour
Use JSX to accomplish this common task directly
This should compile everything to somthing like :
The text was updated successfully, but these errors were encountered: