In the previous post, I reviewed The Reactive primitives of SolidJS. In this article, I'll explore styling and control flow usage of Solid. I should have said this at the end of the post, but I can't wait: As a React developer, I can clearly say that SolidJS is superior to React.
Styling
The way of styling of Solid is a bit different but much better than the React's way.
if you use style prop in React, this will use element.style.setProperty
JS method.
In Solid, you'll have two option when you use style prop. You can use your CSS style in string or in JS object. Also, It should be noted that you should use "dash-case" version of the property.
Control Flow
Show
SolidJS allows us to use ternary operator. However, builtin Show component is used specifically for this case.
Show component has two props when
and fallback
. If when
prop is truthy then the children element will be rendered. Otherwise, fallback
component will be rendered.
Then put Counter component to App component.
It is interesting that fallback
prop accepts those:
It will continue...