Exactly! cloneElement() does just that.
Thank you for the feedback. The article is updated with the implementation. Now the component is merging the classes.
Uodate 2 : using interpolation to concat both className is not a good idea. If children.props.className is undefined, I think you'll have "undefined className" in the new className
That's what happens when you do things in a hurry, hahaah... You were right again. I made this change, what do you think? This was enough to get rid of the undefined.
Using cloneElement, you'll override the className that already exists on the element, right?
I think you need to retrieve the current className and merge with active
Exactly!
cloneElement()
does just that.Thank you for the feedback. The article is updated with the implementation. Now the component is merging the classes.
Uodate 2 : using interpolation to concat both className is not a good idea. If children.props.className is undefined, I think you'll have "undefined className" in the new className
That's what happens when you do things in a hurry, hahaah... You were right again. I made this change, what do you think? This was enough to get rid of the
undefined
.This is better!