SolidJSS
SolidJSโ€ข2y ago
George

`class` vs `classList` behaviour

Hello!

Currently doing something like
const InternalInbox = () => {
  const style = useStyle();

  return (
    <div>
      <button class={style("tw-bg-red-500")}>test</button>
    </div>
  );
};


where useStyle() is just consuming some context and and returning a style function which manipulates the classes based on the context. This seems to not update my class in the DOM after SSR (while I see that the style function runs again on the client.

However, if I use classList ,
`
classList={{[style("tw-bg-red-500")]: true}}


this magically works. Haven't found any issues regarding this. Does it seem like a bug?
Was this page helpful?