Skip to content

Commit

Permalink
Merge pull request #954 from p3ol/fix/next-multi-render
Browse files Browse the repository at this point in the history
🐛 fix: bring back tracking & prevent multiple unwanted renders
  • Loading branch information
dackmin authored Nov 26, 2024
2 parents 17ab34f + 1569c84 commit e512983
Show file tree
Hide file tree
Showing 7 changed files with 57 additions and 58 deletions.
2 changes: 2 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
dist
coverage
node_modules

*.d.ts
2 changes: 1 addition & 1 deletion examples/next/next-env.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
/// <reference types="next/image-types/global" />

// NOTE: This file should not be edited
// see https://nextjs.org/docs/basic-features/typescript for more information.
// see https://nextjs.org/docs/app/building-your-application/configuring/typescript for more information.
2 changes: 1 addition & 1 deletion examples/next/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "poool-react-access-next-example",
"dependencies": {
"@poool/react-access": "portal:../../",
"next": "14.2.5",
"next": "14.2.16",
"react": "18.3.1",
"react-dom": "18.3.1"
},
Expand Down
6 changes: 2 additions & 4 deletions src/AccessContext/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,8 @@ const AccessContext = ({

const init = async () => {
if (
!globalThis.Access ||
!globalThis.Access.isPoool ||
!globalThis.PooolAccess ||
!globalThis.PooolAccess.isPoool
(!globalThis.Access || !globalThis.Access.isPoool) &&
(!globalThis.PooolAccess || !globalThis.PooolAccess.isPoool)
) {
await loadScript(scriptUrl, 'poool-react-access-lib', {
timeout: scriptLoadTimeout,
Expand Down
6 changes: 2 additions & 4 deletions src/AuditContext/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,8 @@ const AuditContext = ({

const init = async () => {
if (
!globalThis.Audit ||
!globalThis.Audit.isPoool ||
!globalThis.PooolAudit ||
!globalThis.PooolAudit.isPoool
(!globalThis.Audit || !globalThis.Audit.isPoool) &&
(!globalThis.PooolAudit || !globalThis.PooolAudit.isPoool)
) {
await loadScript(scriptUrl, 'poool-react-audit-lib', {
timeout: scriptLoadTimeout,
Expand Down
5 changes: 3 additions & 2 deletions src/Paywall/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,10 @@ const Paywall = forwardRef<PaywallRef, PaywallProps>(({
}

container.innerHTML = '';
paywallRef.current.off('identityAvailable', onIdentityAvailable);
await destroyFactory?.(paywallRef.current);
const factory = paywallRef.current;
factory.off('identityAvailable', onIdentityAvailable);
paywallRef.current = null;
await destroyFactory?.(factory);
};

const recreate = async () => {
Expand Down
92 changes: 46 additions & 46 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1010,72 +1010,72 @@ __metadata:
languageName: node
linkType: hard

"@next/env@npm:14.2.5":
version: 14.2.5
resolution: "@next/env@npm:14.2.5"
checksum: 10c0/63d8b88ac450b3c37940a9e2119a63a1074aca89908574ade6157a8aa295275dcb3ac5f69e00883fc55d0f12963b73b74e87ba32a5768a489f9609c6be57b699
"@next/env@npm:14.2.16":
version: 14.2.16
resolution: "@next/env@npm:14.2.16"
checksum: 10c0/e9d795727bc43f171557a7a91111c9b71833840061275b5d4adf96f416febf4f02afb9dac1f4275f4a3e96a0a0db22b58fe934483e2823e76a5d3c60a563394b
languageName: node
linkType: hard

"@next/swc-darwin-arm64@npm:14.2.5":
version: 14.2.5
resolution: "@next/swc-darwin-arm64@npm:14.2.5"
"@next/swc-darwin-arm64@npm:14.2.16":
version: 14.2.16
resolution: "@next/swc-darwin-arm64@npm:14.2.16"
conditions: os=darwin & cpu=arm64
languageName: node
linkType: hard

"@next/swc-darwin-x64@npm:14.2.5":
version: 14.2.5
resolution: "@next/swc-darwin-x64@npm:14.2.5"
"@next/swc-darwin-x64@npm:14.2.16":
version: 14.2.16
resolution: "@next/swc-darwin-x64@npm:14.2.16"
conditions: os=darwin & cpu=x64
languageName: node
linkType: hard

"@next/swc-linux-arm64-gnu@npm:14.2.5":
version: 14.2.5
resolution: "@next/swc-linux-arm64-gnu@npm:14.2.5"
"@next/swc-linux-arm64-gnu@npm:14.2.16":
version: 14.2.16
resolution: "@next/swc-linux-arm64-gnu@npm:14.2.16"
conditions: os=linux & cpu=arm64 & libc=glibc
languageName: node
linkType: hard

"@next/swc-linux-arm64-musl@npm:14.2.5":
version: 14.2.5
resolution: "@next/swc-linux-arm64-musl@npm:14.2.5"
"@next/swc-linux-arm64-musl@npm:14.2.16":
version: 14.2.16
resolution: "@next/swc-linux-arm64-musl@npm:14.2.16"
conditions: os=linux & cpu=arm64 & libc=musl
languageName: node
linkType: hard

"@next/swc-linux-x64-gnu@npm:14.2.5":
version: 14.2.5
resolution: "@next/swc-linux-x64-gnu@npm:14.2.5"
"@next/swc-linux-x64-gnu@npm:14.2.16":
version: 14.2.16
resolution: "@next/swc-linux-x64-gnu@npm:14.2.16"
conditions: os=linux & cpu=x64 & libc=glibc
languageName: node
linkType: hard

"@next/swc-linux-x64-musl@npm:14.2.5":
version: 14.2.5
resolution: "@next/swc-linux-x64-musl@npm:14.2.5"
"@next/swc-linux-x64-musl@npm:14.2.16":
version: 14.2.16
resolution: "@next/swc-linux-x64-musl@npm:14.2.16"
conditions: os=linux & cpu=x64 & libc=musl
languageName: node
linkType: hard

"@next/swc-win32-arm64-msvc@npm:14.2.5":
version: 14.2.5
resolution: "@next/swc-win32-arm64-msvc@npm:14.2.5"
"@next/swc-win32-arm64-msvc@npm:14.2.16":
version: 14.2.16
resolution: "@next/swc-win32-arm64-msvc@npm:14.2.16"
conditions: os=win32 & cpu=arm64
languageName: node
linkType: hard

"@next/swc-win32-ia32-msvc@npm:14.2.5":
version: 14.2.5
resolution: "@next/swc-win32-ia32-msvc@npm:14.2.5"
"@next/swc-win32-ia32-msvc@npm:14.2.16":
version: 14.2.16
resolution: "@next/swc-win32-ia32-msvc@npm:14.2.16"
conditions: os=win32 & cpu=ia32
languageName: node
linkType: hard

"@next/swc-win32-x64-msvc@npm:14.2.5":
version: 14.2.5
resolution: "@next/swc-win32-x64-msvc@npm:14.2.5"
"@next/swc-win32-x64-msvc@npm:14.2.16":
version: 14.2.16
resolution: "@next/swc-win32-x64-msvc@npm:14.2.16"
conditions: os=win32 & cpu=x64
languageName: node
linkType: hard
Expand Down Expand Up @@ -8305,20 +8305,20 @@ __metadata:
languageName: node
linkType: hard

"next@npm:14.2.5":
version: 14.2.5
resolution: "next@npm:14.2.5"
"next@npm:14.2.16":
version: 14.2.16
resolution: "next@npm:14.2.16"
dependencies:
"@next/env": "npm:14.2.5"
"@next/swc-darwin-arm64": "npm:14.2.5"
"@next/swc-darwin-x64": "npm:14.2.5"
"@next/swc-linux-arm64-gnu": "npm:14.2.5"
"@next/swc-linux-arm64-musl": "npm:14.2.5"
"@next/swc-linux-x64-gnu": "npm:14.2.5"
"@next/swc-linux-x64-musl": "npm:14.2.5"
"@next/swc-win32-arm64-msvc": "npm:14.2.5"
"@next/swc-win32-ia32-msvc": "npm:14.2.5"
"@next/swc-win32-x64-msvc": "npm:14.2.5"
"@next/env": "npm:14.2.16"
"@next/swc-darwin-arm64": "npm:14.2.16"
"@next/swc-darwin-x64": "npm:14.2.16"
"@next/swc-linux-arm64-gnu": "npm:14.2.16"
"@next/swc-linux-arm64-musl": "npm:14.2.16"
"@next/swc-linux-x64-gnu": "npm:14.2.16"
"@next/swc-linux-x64-musl": "npm:14.2.16"
"@next/swc-win32-arm64-msvc": "npm:14.2.16"
"@next/swc-win32-ia32-msvc": "npm:14.2.16"
"@next/swc-win32-x64-msvc": "npm:14.2.16"
"@swc/helpers": "npm:0.5.5"
busboy: "npm:1.6.0"
caniuse-lite: "npm:^1.0.30001579"
Expand Down Expand Up @@ -8359,7 +8359,7 @@ __metadata:
optional: true
bin:
next: dist/bin/next
checksum: 10c0/8df7d8ccc1a5bab03fa50dd6656c8a6f3750e81ef0b087dc329fea9346847c3094a933a890a8e87151dc32f0bc55020b8f6386d4565856d83bcc10895d29ec08
checksum: 10c0/8cd036a6f30d4cc8ab8480c19339ee6134ffd5b18338ff5a07de397ed4e29fad54de5219f70aafabf1fe9c48a7d54b7df58ba1f29cfa5d3351ff7763e8d4844e
languageName: node
linkType: hard

Expand Down Expand Up @@ -8969,7 +8969,7 @@ __metadata:
resolution: "poool-react-access-next-example@workspace:examples/next"
dependencies:
"@poool/react-access": "portal:../../"
next: "npm:14.2.5"
next: "npm:14.2.16"
react: "npm:18.3.1"
react-dom: "npm:18.3.1"
languageName: unknown
Expand Down

0 comments on commit e512983

Please sign in to comment.