react-usectx 1.0.0 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,2 +1,79 @@
1
1
  # React-Context
2
+
2
3
  Custom React globally accessible context hook
4
+
5
+ ## Installation
6
+
7
+ ```
8
+ npm i react-usectx --save
9
+ ```
10
+
11
+ ## Add it to your project
12
+
13
+ ```js
14
+ import ususeCtx from "react-usectx";
15
+ ```
16
+
17
+ ## Usage
18
+
19
+ ```js
20
+ // get both current state and set function
21
+ const [myContext, setMyContext] = useCtx("stateName");
22
+ ```
23
+
24
+ ## Other methods:
25
+
26
+ ### getCtx
27
+
28
+ ```js
29
+ // get current state only
30
+
31
+ import { getCtx } from "react-usectx";
32
+
33
+ const myContext = getCtx("stateName");
34
+ ```
35
+
36
+ ### updateCtx
37
+
38
+ ```js
39
+ // set function only
40
+
41
+ import { updateCtx } from "react-usectx";
42
+
43
+ const setMyContext = updateCtx("stateName");
44
+
45
+ setMyContext({ name: "Rick Ross" });
46
+ ```
47
+
48
+ ## Example
49
+
50
+ ```js
51
+ function Page() {
52
+ const [title, setTitle] = useCtx("title");
53
+
54
+ return (
55
+ <div className="wrapper">
56
+ <form>
57
+ <label htmlFor="text">Enter text</label>
58
+ <input
59
+ type="text"
60
+ id="text"
61
+ onChange={(e) => setTitle(e.target.value)}
62
+ />
63
+ </form>
64
+ <Title></Title>
65
+ <p>{title}</p>
66
+ </div>
67
+ );
68
+ }
69
+
70
+ function Title() {
71
+ const title: string = getContext("title");
72
+ return (
73
+ <h1>
74
+ Component: <br />
75
+ <strong>{title}</strong>
76
+ </h1>
77
+ );
78
+ }
79
+ ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-usectx",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "main": "index.js",
5
5
  "scripts": {
6
6
  "test": "jest"
File without changes