Open rafikalid opened 1 year ago
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 ]
});
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.
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 :