diff options
Diffstat (limited to 'example/index.tsx')
-rw-r--r-- | example/index.tsx | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/example/index.tsx b/example/index.tsx index 89c325d..566ebaf 100644 --- a/example/index.tsx +++ b/example/index.tsx @@ -2,7 +2,7 @@ import React, { useState } from "react" import { createContainer } from "../src/unstated-next" import { render } from "react-dom" -function useCounter() { +function useCounter(initialState = 0) { let [count, setCount] = useState(initialState) let decrement = () => setCount(count - 1) let increment = () => setCount(count + 1) @@ -14,11 +14,11 @@ let Counter = createContainer(useCounter) function CounterDisplay() { let counter = Counter.useContainer() return ( - <> + <div> <button onClick={counter.decrement}>-</button> <span>{counter.count}</span> <button onClick={counter.increment}>+</button> - </> + </div> ) } @@ -26,7 +26,7 @@ function App() { return ( <Counter.Provider> <CounterDisplay /> - <Counter.Provider> + <Counter.Provider initialState={2}> <div> <div> <CounterDisplay /> |