@graffy/react 0.16.1 → 0.16.2
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/index.cjs +8 -14
- package/index.mjs +1 -3
- package/package.json +2 -2
package/index.cjs
CHANGED
|
@@ -1,24 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const React = require("react");
|
|
4
4
|
const PropTypes = require("prop-types");
|
|
5
5
|
const isEqual = require("lodash/isEqual.js");
|
|
6
|
-
const
|
|
7
|
-
const React__default = /* @__PURE__ */ _interopDefaultLegacy(React);
|
|
8
|
-
const PropTypes__default = /* @__PURE__ */ _interopDefaultLegacy(PropTypes);
|
|
9
|
-
const isEqual__default = /* @__PURE__ */ _interopDefaultLegacy(isEqual);
|
|
10
|
-
const { createContext } = React__default.default;
|
|
6
|
+
const { createContext } = React;
|
|
11
7
|
const GraffyContext = createContext(null);
|
|
12
8
|
function GraffyProvider({ store, children }) {
|
|
13
|
-
return /* @__PURE__ */
|
|
14
|
-
value: store
|
|
15
|
-
}, children);
|
|
9
|
+
return /* @__PURE__ */ React.createElement(GraffyContext.Provider, { value: store }, children);
|
|
16
10
|
}
|
|
17
11
|
GraffyProvider.propTypes = {
|
|
18
|
-
store:
|
|
19
|
-
children:
|
|
12
|
+
store: PropTypes.object.isRequired,
|
|
13
|
+
children: PropTypes.node
|
|
20
14
|
};
|
|
21
|
-
const { useRef, useState, useEffect, useContext: useContext$1 } =
|
|
15
|
+
const { useRef, useState, useEffect, useContext: useContext$1 } = React;
|
|
22
16
|
const consumeSubscription = async (subscription, setState) => {
|
|
23
17
|
try {
|
|
24
18
|
for await (const data of subscription) {
|
|
@@ -64,7 +58,7 @@ function useQuery(query, { once = false, ...other } = {}) {
|
|
|
64
58
|
const queryRef = useRef(null);
|
|
65
59
|
if (!store)
|
|
66
60
|
throw Error("graffy_react.no_store_in_context");
|
|
67
|
-
const queryHasChanged = !
|
|
61
|
+
const queryHasChanged = !isEqual(queryRef.current, query);
|
|
68
62
|
if (queryHasChanged) {
|
|
69
63
|
queryRef.current = query;
|
|
70
64
|
}
|
|
@@ -91,7 +85,7 @@ function Query({ query, options, children }) {
|
|
|
91
85
|
const { data, loading, error } = useQuery(query, options);
|
|
92
86
|
return children({ data, loading, error });
|
|
93
87
|
}
|
|
94
|
-
const { useContext } =
|
|
88
|
+
const { useContext } = React;
|
|
95
89
|
function useStore() {
|
|
96
90
|
const store = useContext(GraffyContext);
|
|
97
91
|
return store;
|
package/index.mjs
CHANGED
|
@@ -4,9 +4,7 @@ import isEqual from "lodash/isEqual.js";
|
|
|
4
4
|
const { createContext } = React;
|
|
5
5
|
const GraffyContext = createContext(null);
|
|
6
6
|
function GraffyProvider({ store, children }) {
|
|
7
|
-
return /* @__PURE__ */ React.createElement(GraffyContext.Provider, {
|
|
8
|
-
value: store
|
|
9
|
-
}, children);
|
|
7
|
+
return /* @__PURE__ */ React.createElement(GraffyContext.Provider, { value: store }, children);
|
|
10
8
|
}
|
|
11
9
|
GraffyProvider.propTypes = {
|
|
12
10
|
store: PropTypes.object.isRequired,
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@graffy/react",
|
|
3
3
|
"description": "This built-in module provides an idiomatic React API to a Graffy store.",
|
|
4
4
|
"author": "aravind (https://github.com/aravindet)",
|
|
5
|
-
"version": "0.16.
|
|
5
|
+
"version": "0.16.2",
|
|
6
6
|
"main": "./index.cjs",
|
|
7
7
|
"exports": {
|
|
8
8
|
"import": "./index.mjs",
|
|
@@ -20,6 +20,6 @@
|
|
|
20
20
|
"prop-types": "^15.8.1"
|
|
21
21
|
},
|
|
22
22
|
"peerDependencies": {
|
|
23
|
-
"react": "^16.8.0 || ^17.0.0"
|
|
23
|
+
"react": "^16.8.0 || ^17.0.0 || ^18.0.0"
|
|
24
24
|
}
|
|
25
25
|
}
|