SolidJS — React meets Svelte?

Setting Up a SolidJS Project

What’s the same

State

import {createSignal} from "solid-js"
import './App.css';
function App() { // create state
const [count, setCount] = createSignal(1)
// add function
const add = () => {
//notice in this context I must invoke the state to get the value (not in jsx)
setCount(count() + 1)
}
// JSX works like normal
return (
<div class="App">
<h1>My Counter</h1>
<h2>{count}</h2>
<button onClick={add}>Add</button>
</div>
);
}
export default App;

Lifecycle and createEffect

Bottom Line

Alex Merced is a Full Stack Developer, learn more about his work at AlexMercedCoder.com

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store