aboutsummaryrefslogtreecommitdiff
path: root/example
diff options
context:
space:
mode:
authorJamie Kyle <me@thejameskyle.com>2019-05-14 02:31:32 +0300
committerJamie Kyle <me@thejameskyle.com>2019-05-14 02:31:32 +0300
commitf75e4529109640e39e527cdadda66d5e748ab1bf (patch)
tree0edacda1d2ad832e034a86d5c47c540d37c43f0d /example
parentbadab5b6aba05a76abeb5e87fc4c531fd1a04d68 (diff)
add initialState
Diffstat (limited to 'example')
-rw-r--r--example/index.tsx16
1 files changed, 9 insertions, 7 deletions
diff --git a/example/index.tsx b/example/index.tsx
index c967d9d..89c325d 100644
--- a/example/index.tsx
+++ b/example/index.tsx
@@ -1,9 +1,9 @@
import React, { useState } from "react"
-import { Provider, createContainer } from "../src/unstated"
+import { createContainer } from "../src/unstated-next"
import { render } from "react-dom"
function useCounter() {
- let [count, setCount] = useState(0)
+ let [count, setCount] = useState(initialState)
let decrement = () => setCount(count - 1)
let increment = () => setCount(count + 1)
return { count, decrement, increment }
@@ -24,14 +24,16 @@ function CounterDisplay() {
function App() {
return (
- <Provider>
+ <Counter.Provider>
<CounterDisplay />
- <div>
+ <Counter.Provider>
<div>
- <CounterDisplay />
+ <div>
+ <CounterDisplay />
+ </div>
</div>
- </div>
- </Provider>
+ </Counter.Provider>
+ </Counter.Provider>
)
}