Skip to content

Commit a5f42da

Browse files
liuyunliuyun
authored andcommitted
文档更新
1 parent ed8d482 commit a5f42da

File tree

14 files changed

+60
-22
lines changed

14 files changed

+60
-22
lines changed

README.md

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ Write local state using [React Hooks](https://reactjs.org/docs/hooks-intro.html)
3838

3939
```jsx
4040
import React, { useState } from "react";
41-
import constate from "constate";
41+
import constate from "@liuyunjs/constate";
4242

4343
// 1️⃣ Create a custom hook as usual
4444
function useCounter() {
@@ -63,6 +63,14 @@ function Count() {
6363
}
6464

6565
function App() {
66+
// const [inject] = CounterProvider.useProvider();
67+
68+
// return inject(
69+
// <>
70+
// <Count />
71+
// <Button />
72+
// </>
73+
// )
6674
// 5️⃣ Wrap your components with Provider
6775
return (
6876
<CounterProvider>
@@ -79,7 +87,7 @@ function App() {
7987

8088
```jsx
8189
import React, { useState, useCallback } from "react";
82-
import constate from "constate";
90+
import constate from "@liuyunjs/constate";
8391

8492
// 1️⃣ Create a custom hook that receives props
8593
function useCounter({ initialCount = 0 }) {
@@ -109,6 +117,15 @@ function Count() {
109117
}
110118

111119
function App() {
120+
// const [inject] = CounterProvider.useProvider({initialCount: 10});
121+
122+
// return inject(
123+
// <>
124+
// <Count />
125+
// <Button />
126+
// </>
127+
// )
128+
112129
// 6️⃣ Wrap your components with Provider passing props to your hook
113130
return (
114131
<CounterProvider initialCount={10}>
@@ -147,7 +164,7 @@ It's any [custom hook](https://reactjs.org/docs/hooks-custom.html):
147164

148165
```js
149166
import { useState } from "react";
150-
import constate from "constate";
167+
import constate from "@liuyunjs/constate";
151168

152169
const [CountProvider, useCountContext] = constate(() => {
153170
const [count] = useState(0);
@@ -164,6 +181,12 @@ const [CountProvider, useCountContext] = constate(({ initialCount = 0 }) => {
164181
});
165182

166183
function App() {
184+
// const [inject] = CounterProvider.useProvider({initialCount: 10});
185+
186+
// return inject(
187+
// ...
188+
// )
189+
167190
return (
168191
<CountProvider initialCount={10}>
169192
...
@@ -189,7 +212,7 @@ A `selector` function receives the value returned by [`useValue`](#usevalue) and
189212

190213
```jsx
191214
import React, { useState, useCallback } from "react";
192-
import constate from "constate";
215+
import constate from "@liuyunjs/constate";
193216

194217
function useCounter() {
195218
const [count, setCount] = useState(0);

examples/counter/App.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React, { useState } from "react";
2-
import constate from "constate";
2+
import constate from "@liuyunjs/constate";
33

44
// 1️⃣ Create a custom hook as usual
55
function useCounter() {
@@ -24,6 +24,14 @@ function Count() {
2424
}
2525

2626
function App() {
27+
// const [inject] = CounterProvider.useProvider();
28+
// return inject(
29+
// <>
30+
// <Count />
31+
// <Button />
32+
// </>
33+
// );
34+
2735
// 5️⃣ Wrap your components with Provider
2836
return (
2937
<CounterProvider>

examples/counter/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"build": "parcel build index.html"
1616
},
1717
"dependencies": {
18-
"constate": "3.2.0",
18+
"@liuyunjs/constate": "3.3.0",
1919
"parcel-bundler": "1.12.4",
2020
"react": "17.0.1",
2121
"react-dom": "17.0.1"

examples/i18n/App.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React, { useState } from "react";
2-
import constate from "constate";
2+
import constate from "@liuyunjs/constate";
33

44
const translations = {
55
en: {

examples/i18n/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"build": "parcel build index.html"
1717
},
1818
"dependencies": {
19-
"constate": "3.2.0",
19+
"@liuyunjs/constate": "3.3.0",
2020
"parcel-bundler": "1.12.4",
2121
"react": "17.0.1",
2222
"react-dom": "17.0.1"

examples/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"react-dom": "17.0.1"
1515
},
1616
"alias": {
17-
"constate": "../src",
17+
"@liuyunjs/constate": "../src",
1818
"react": "./node_modules/react",
1919
"react-dom": "./node_modules/react-dom"
2020
}

examples/theming/App.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React, { useState } from "react";
22
import { GithubPicker } from "react-color";
3-
import constate from "constate";
3+
import constate from "@liuyunjs/constate";
44

55
const [ThemeProvider, useThemeContext, useThemeColor] = constate(
66
(props) => useState(props.initialColor),

examples/theming/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"build": "parcel build index.html"
1717
},
1818
"dependencies": {
19-
"constate": "3.2.0",
19+
"@liuyunjs/constate": "3.3.0",
2020
"parcel-bundler": "1.12.4",
2121
"react": "17.0.1",
2222
"react-color": "2.19.3",

examples/typescript/App.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// It just works! No need to type anything explicitly.
22
import * as React from "react";
3-
import constate from "constate";
3+
import constate from "@liuyunjs/constate";
44

55
function useCounter({ initialCount = 0 } = {}) {
66
const [count, setCount] = React.useState(initialCount);

examples/typescript/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
"dependencies": {
1818
"@types/react": "16.9.53",
1919
"@types/react-dom": "16.9.8",
20-
"constate": "3.2.0",
20+
"@liuyunjs/constate": "3.3.0",
2121
"parcel-bundler": "1.12.4",
2222
"react": "17.0.1",
2323
"react-dom": "17.0.1",

0 commit comments

Comments
 (0)