Advertisement
codergautamyt

Solidjs counter

Apr 1st, 2022
1,128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import { createSignal, onMount } from "solid-js";
  2.  
  3. function App() {
  4.   const [count, setCount] = createSignal(0);
  5.   let input;
  6.  
  7.   onMount(() => {
  8.     console.log("Everything is ready!")
  9.   });
  10.  
  11.   return (
  12.     <div>
  13.       <input
  14.         type="number"
  15.         ref={input}
  16.         placeholder="Enter a number"
  17.       />
  18.       <button onClick={() => setCount(count()+parseInt(input.value))}>
  19.         Add
  20.       </button>
  21.       <p>{count()}</p>
  22.     </div>
  23.   )
  24. }
  25. export default App;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement