index.tsx
This file
Path
examples/starter/src/index.tsx
61 lines · 1.2 KiB · TypeScript
Last changed by
Not known.
History of this fileTake it
The walk stopped after 200 commits: lines older than f85898f point at it.
chore(eslint.config.mjs): update 'eslint-plugin-react-hooks', 'eslint-plugin-react-compiler' config (#3043)Wonsuk Choibefore adoptionf85898f
lines 1–61why, one step back1import { StrictMode } from 'react'2import { createRoot } from 'react-dom/client'3import { create } from 'zustand'45import mascot from './assets/zustand-mascot.svg'67import './index.css'89type Store = {10 count: number11 inc: () => void12}1314const useStore = create<Store>((set) => ({15 count: 0,16 inc: () => set((state) => ({ count: state.count + 1 })),17}))1819const Counter = () => {20 const count = useStore((s) => s.count)21 const inc = useStore((s) => s.inc)2223 return (24 <>25 <span className="text-3xl">{count}</span>26 <button27 className="bg-[#252b37] font-bold py-2 px-4 rounded"28 onClick={inc}29 >30 +131 </button>32 </>33 )34}3536function App() {37 return (38 <div className="grid place-items-center gap-6">39 <a href="https://zustand-demo.pmnd.rs/" target="_blank" rel="noreferrer">40 <img41 src={mascot}42 alt="Zustand mascot"43 className="w-36"44 style={{45 filter: 'drop-shadow(0 0 2em #582d3e)',46 }}47 />48 </a>4950 <h1 className="text-5xl font-bold">Zustand Starter</h1>5152 <Counter />53 </div>54 )55}5657createRoot(document.getElementById('root')!).render(58 <StrictMode>59 <App />60 </StrictMode>,61)