From React to Atomico
Atomico inherits part of the React syntax and applies it to webcomponents, with a closer to standard approach.
If you develop with React, you will know 80% Atomico ... now why use Atomico?:
Counter example
import { useState } from "react";
import ReactDOM from 'react-dom'
function Counter({initialCount}) {
const [count, setCount] = useState(initialCount);
return (
<>
Count: {count}
<button onClick={() => setCount(initialCount)}>Reset</button>
<button onClick={() => setCount(prevCount => prevCount - 1)}>-</button>
<button onClick={() => setCount(prevCount => prevCount + 1)}>+</button>
</>
);
}
render(
<Counter initialCount={1}/>,
document.querySelector("#counter")
);import { c, useProp } from "atomico";
function counter() {
const [count, setCount] = useProp("count");
return (
<host>
Count: {count}
<button onClick={() => setCount(prevCount => prevCount - 1)}>-</button>
<button onClick={() => setCount(prevCount => prevCount + 1)}>+</button>
</host>
);
}
counter.props = { count: { type: Number, value: 0 } }
const Counter = c(counter);
customElements.define(
"my-counter",
Counter
);CustomHooks example
Supported hooks
CSS-in-JS
Last updated
Was this helpful?
