What's the simplest way to combine the classList prop?
I have a component that takes a classList prop, and I want to combine it with a reactive classList object of its own before setting it on an internal element. What's the easiest way to do that while keeping the prop and the internal object reactive?
2 Replies
if you spread both in the prop, it should be reactive
classList={{ ...props.classList, sthElse: isEnabled() }}
you can also use combineProps
to combine multiple props at once: https://github.com/solidjs-community/solid-primitives/tree/main/packages/props#combinepropsWouldn't spreading the props break the individual add/remove class? or does it diff the object?