@knocklabs/react-core 0.2.13 → 0.2.14

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/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.2.14
4
+
5
+ ### Patch Changes
6
+
7
+ - 5fe3063: Fixes issue where notification data was not updating in react strict mode
8
+
3
9
  ## 0.2.13
4
10
 
5
11
  ### Patch Changes
@@ -1,2 +1,2 @@
1
- "use strict";const n=require("react");function u(s,i,e={}){const t=n.useRef();return n.useMemo(()=>{t.current&&t.current.dispose();const r=s.feeds.initialize(i,e);return r.listenForUpdates(),t.current=r,r},[s,i,e.source,e.tenant,e.has_tenant,e.archived])}module.exports=u;
1
+ "use strict";const c=require("react");function i(t,s,e={}){const r=c.useRef();return c.useMemo(()=>(r.current&&r.current.dispose(),r.current=t.feeds.initialize(s,e),r.current.listenForUpdates(),r.current.store.subscribe(n=>{var u;return(u=r==null?void 0:r.current)==null?void 0:u.store.setState(n)}),r.current),[t,s,e.source,e.tenant,e.has_tenant,e.archived])}module.exports=i;
2
2
  //# sourceMappingURL=useNotifications.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"useNotifications.js","sources":["../../../../../src/modules/feed/hooks/useNotifications.ts"],"sourcesContent":["import Knock, { Feed, FeedClientOptions } from \"@knocklabs/client\";\nimport { useMemo, useRef } from \"react\";\n\nfunction useNotifications(\n knock: Knock,\n feedChannelId: string,\n options: FeedClientOptions = {},\n) {\n const feedClientRef = useRef<Feed | null>();\n\n return useMemo(() => {\n if (feedClientRef.current) {\n feedClientRef.current.dispose();\n }\n\n const feedClient = knock.feeds.initialize(feedChannelId, options);\n\n feedClient.listenForUpdates();\n feedClientRef.current = feedClient;\n\n return feedClient;\n }, [\n knock,\n feedChannelId,\n options.source,\n options.tenant,\n options.has_tenant,\n options.archived,\n ]);\n}\n\nexport default useNotifications;\n"],"names":["useNotifications","knock","feedChannelId","options","feedClientRef","useRef","useMemo","current","dispose","feedClient","feeds","initialize","listenForUpdates","source","tenant","has_tenant","archived"],"mappings":"sCAGA,SAASA,EACPC,EACAC,EACAC,EAA6B,CAAA,EAC7B,CACA,MAAMC,EAAgBC,EAAAA,SAEtB,OAAOC,UAAQ,IAAM,CACfF,EAAcG,SAChBH,EAAcG,QAAQC,UAGxB,MAAMC,EAAaR,EAAMS,MAAMC,WAAWT,EAAeC,CAAO,EAEhEM,OAAAA,EAAWG,iBAAiB,EAC5BR,EAAcG,QAAUE,EAEjBA,CACN,EAAA,CACDR,EACAC,EACAC,EAAQU,OACRV,EAAQW,OACRX,EAAQY,WACRZ,EAAQa,QAAQ,CACjB,CACH"}
1
+ {"version":3,"file":"useNotifications.js","sources":["../../../../../src/modules/feed/hooks/useNotifications.ts"],"sourcesContent":["import Knock, { Feed, FeedClientOptions } from \"@knocklabs/client\";\nimport { useMemo, useRef } from \"react\";\n\nfunction useNotifications(\n knock: Knock,\n feedChannelId: string,\n options: FeedClientOptions = {},\n) {\n const feedClientRef = useRef<Feed | null>();\n\n return useMemo(() => {\n if (feedClientRef.current) {\n feedClientRef.current.dispose();\n }\n\n feedClientRef.current = knock.feeds.initialize(feedChannelId, options);\n feedClientRef.current.listenForUpdates();\n feedClientRef.current.store.subscribe((t) =>\n feedClientRef?.current?.store.setState(t),\n );\n\n return feedClientRef.current;\n }, [\n knock,\n feedChannelId,\n options.source,\n options.tenant,\n options.has_tenant,\n options.archived,\n ]);\n}\n\nexport default useNotifications;\n"],"names":["useNotifications","knock","feedChannelId","options","feedClientRef","useRef","useMemo","current","dispose","feeds","initialize","listenForUpdates","store","subscribe","t","setState","source","tenant","has_tenant","archived"],"mappings":"sCAGA,SAASA,EACPC,EACAC,EACAC,EAA6B,CAAA,EAC7B,CACA,MAAMC,EAAgBC,EAAAA,SAEtB,OAAOC,UAAQ,KACTF,EAAcG,SAChBH,EAAcG,QAAQC,UAGxBJ,EAAcG,QAAUN,EAAMQ,MAAMC,WAAWR,EAAeC,CAAO,EACrEC,EAAcG,QAAQI,mBACRJ,EAAAA,QAAQK,MAAMC,UAAWC,GAAAA,OACrCV,OAAAA,EAAAA,GAAAA,YAAAA,EAAeG,UAAfH,YAAAA,EAAwBQ,MAAMG,SAASD,GACzC,EAEOV,EAAcG,SACpB,CACDN,EACAC,EACAC,EAAQa,OACRb,EAAQc,OACRd,EAAQe,WACRf,EAAQgB,QAAQ,CACjB,CACH"}
@@ -1,13 +1,12 @@
1
- import { useRef as u, useMemo as s } from "react";
2
- function a(i, n, e = {}) {
3
- const t = u();
4
- return s(() => {
5
- t.current && t.current.dispose();
6
- const r = i.feeds.initialize(n, e);
7
- return r.listenForUpdates(), t.current = r, r;
8
- }, [i, n, e.source, e.tenant, e.has_tenant, e.archived]);
1
+ import { useRef as n, useMemo as a } from "react";
2
+ function f(t, u, e = {}) {
3
+ const r = n();
4
+ return a(() => (r.current && r.current.dispose(), r.current = t.feeds.initialize(u, e), r.current.listenForUpdates(), r.current.store.subscribe((c) => {
5
+ var s;
6
+ return (s = r == null ? void 0 : r.current) == null ? void 0 : s.store.setState(c);
7
+ }), r.current), [t, u, e.source, e.tenant, e.has_tenant, e.archived]);
9
8
  }
10
9
  export {
11
- a as default
10
+ f as default
12
11
  };
13
12
  //# sourceMappingURL=useNotifications.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"useNotifications.mjs","sources":["../../../../../src/modules/feed/hooks/useNotifications.ts"],"sourcesContent":["import Knock, { Feed, FeedClientOptions } from \"@knocklabs/client\";\nimport { useMemo, useRef } from \"react\";\n\nfunction useNotifications(\n knock: Knock,\n feedChannelId: string,\n options: FeedClientOptions = {},\n) {\n const feedClientRef = useRef<Feed | null>();\n\n return useMemo(() => {\n if (feedClientRef.current) {\n feedClientRef.current.dispose();\n }\n\n const feedClient = knock.feeds.initialize(feedChannelId, options);\n\n feedClient.listenForUpdates();\n feedClientRef.current = feedClient;\n\n return feedClient;\n }, [\n knock,\n feedChannelId,\n options.source,\n options.tenant,\n options.has_tenant,\n options.archived,\n ]);\n}\n\nexport default useNotifications;\n"],"names":["useNotifications","knock","feedChannelId","options","feedClientRef","useRef","useMemo","current","dispose","feedClient","feeds","initialize","listenForUpdates","source","tenant","has_tenant","archived"],"mappings":";AAGA,SAASA,EACPC,GACAC,GACAC,IAA6B,CAAA,GAC7B;AACA,QAAMC,IAAgBC;AAEtB,SAAOC,EAAQ,MAAM;AACnB,IAAIF,EAAcG,WAChBH,EAAcG,QAAQC;AAGxB,UAAMC,IAAaR,EAAMS,MAAMC,WAAWT,GAAeC,CAAO;AAEhEM,WAAAA,EAAWG,iBAAiB,GAC5BR,EAAcG,UAAUE,GAEjBA;AAAAA,EACN,GAAA,CACDR,GACAC,GACAC,EAAQU,QACRV,EAAQW,QACRX,EAAQY,YACRZ,EAAQa,QAAQ,CACjB;AACH;"}
1
+ {"version":3,"file":"useNotifications.mjs","sources":["../../../../../src/modules/feed/hooks/useNotifications.ts"],"sourcesContent":["import Knock, { Feed, FeedClientOptions } from \"@knocklabs/client\";\nimport { useMemo, useRef } from \"react\";\n\nfunction useNotifications(\n knock: Knock,\n feedChannelId: string,\n options: FeedClientOptions = {},\n) {\n const feedClientRef = useRef<Feed | null>();\n\n return useMemo(() => {\n if (feedClientRef.current) {\n feedClientRef.current.dispose();\n }\n\n feedClientRef.current = knock.feeds.initialize(feedChannelId, options);\n feedClientRef.current.listenForUpdates();\n feedClientRef.current.store.subscribe((t) =>\n feedClientRef?.current?.store.setState(t),\n );\n\n return feedClientRef.current;\n }, [\n knock,\n feedChannelId,\n options.source,\n options.tenant,\n options.has_tenant,\n options.archived,\n ]);\n}\n\nexport default useNotifications;\n"],"names":["useNotifications","knock","feedChannelId","options","feedClientRef","useRef","useMemo","current","dispose","feeds","initialize","listenForUpdates","store","subscribe","t","setState","source","tenant","has_tenant","archived"],"mappings":";AAGA,SAASA,EACPC,GACAC,GACAC,IAA6B,CAAA,GAC7B;AACA,QAAMC,IAAgBC;AAEtB,SAAOC,EAAQ,OACTF,EAAcG,WAChBH,EAAcG,QAAQC,WAGxBJ,EAAcG,UAAUN,EAAMQ,MAAMC,WAAWR,GAAeC,CAAO,GACrEC,EAAcG,QAAQI,oBACRJ,EAAAA,QAAQK,MAAMC,UAAWC,CAAAA,MAAAA;;AACrCV,YAAAA,IAAAA,KAAAA,gBAAAA,EAAeG,YAAfH,gBAAAA,EAAwBQ,MAAMG,SAASD;AAAAA,GACzC,GAEOV,EAAcG,UACpB,CACDN,GACAC,GACAC,EAAQa,QACRb,EAAQc,QACRd,EAAQe,YACRf,EAAQgB,QAAQ,CACjB;AACH;"}
@@ -1 +1 @@
1
- {"version":3,"file":"useNotifications.d.ts","sourceRoot":"","sources":["../../../../../src/modules/feed/hooks/useNotifications.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,IAAI,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAGnE,iBAAS,gBAAgB,CACvB,KAAK,EAAE,KAAK,EACZ,aAAa,EAAE,MAAM,EACrB,OAAO,GAAE,iBAAsB,QAuBhC;AAED,eAAe,gBAAgB,CAAC"}
1
+ {"version":3,"file":"useNotifications.d.ts","sourceRoot":"","sources":["../../../../../src/modules/feed/hooks/useNotifications.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,IAAI,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAGnE,iBAAS,gBAAgB,CACvB,KAAK,EAAE,KAAK,EACZ,aAAa,EAAE,MAAM,EACrB,OAAO,GAAE,iBAAsB,QAwBhC;AAED,eAAe,gBAAgB,CAAC"}
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@knocklabs/react-core",
3
3
  "description": "A set of React components to build notification experiences powered by Knock",
4
4
  "author": "@knocklabs",
5
- "version": "0.2.13",
5
+ "version": "0.2.14",
6
6
  "license": "MIT",
7
7
  "main": "dist/cjs/index.js",
8
8
  "module": "dist/esm/index.mjs",
@@ -1,5 +1,5 @@
1
1
  import Knock, { Feed, FeedClientOptions } from "@knocklabs/client";
2
- import { useMemo, useRef } from "react";
2
+ import { useMemo, useRef } from "react";
3
3
 
4
4
  function useNotifications(
5
5
  knock: Knock,
@@ -13,12 +13,13 @@ function useNotifications(
13
13
  feedClientRef.current.dispose();
14
14
  }
15
15
 
16
- const feedClient = knock.feeds.initialize(feedChannelId, options);
16
+ feedClientRef.current = knock.feeds.initialize(feedChannelId, options);
17
+ feedClientRef.current.listenForUpdates();
18
+ feedClientRef.current.store.subscribe((t) =>
19
+ feedClientRef?.current?.store.setState(t),
20
+ );
17
21
 
18
- feedClient.listenForUpdates();
19
- feedClientRef.current = feedClient;
20
-
21
- return feedClient;
22
+ return feedClientRef.current;
22
23
  }, [
23
24
  knock,
24
25
  feedChannelId,