diff options
author | Jamie Kyle <me@thejameskyle.com> | 2019-05-14 03:01:10 +0300 |
---|---|---|
committer | Jamie Kyle <me@thejameskyle.com> | 2019-05-14 03:01:10 +0300 |
commit | 73164696df42aa9df9eb05c8d3f6982ff92a06ec (patch) | |
tree | 069098244c7dad5d26a1020d583fda71cc83fe17 /example/index.tsx | |
parent | f76101a87ded9e55393f83ac7869997aacf62b70 (diff) |
fix example
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 /> |