Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(ui): stale locale value from useLocale #9582

Merged
merged 11 commits into from
Dec 4, 2024

Conversation

JarrodMFlesch
Copy link
Contributor

@JarrodMFlesch JarrodMFlesch commented Nov 27, 2024

What?

Fixes issue with stale locale from searchParams

Why?

Bad use of useEffect/useState inside our useSearchParams provider.

How?

Memoize the locale instead of relying on the useEffect which was causing unnecessary renders with stale values.

@@ -21,70 +21,44 @@ export const LocaleProvider: React.FC<{ children?: React.ReactNode }> = ({ child
const defaultLocale =
localization && localization.defaultLocale ? localization.defaultLocale : 'en'

const { getPreference, setPreference } = usePreferences()
const { searchParams } = useSearchParams()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of relying on the search params provider for locale here, you should use next/navigation directly and parse the search params yourself. Check out #9581

@JarrodMFlesch JarrodMFlesch changed the title fix: stale locale value from useLocale fix(ui): stale locale value from useLocale Nov 27, 2024
Copy link

socket-security bot commented Dec 4, 2024

🚨 Potential security issues detected. Learn more about Socket for GitHub ↗︎

To accept the risk, merge this PR and you will not be notified again.

Alert Package NoteSourceCI
Possible typosquat attack npm/object.assign@4.1.5 ⚠︎
Possible typosquat attack npm/types-react-dom@19.0.0-rc.1 ⚠︎
Possible typosquat attack npm/@nolyfill/is-core-module@1.0.39 ⚠︎

View full report↗︎

Next steps

What is a typosquat?

Package name is similar to other popular packages and may not be the package you want.

Use care when consuming similarly named packages and ensure that you did not intend to consume a different package. Malicious packages often publish using similar names as existing popular packages.

Take a deeper look at the dependency

Take a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at support [AT] socket [DOT] dev.

Remove the package

If you happen to install a dependency that Socket reports as Known Malware you should immediately remove it and select a different dependency. For other alert types, you may may wish to investigate alternative packages or consider if there are other ways to mitigate the specific risk posed by the dependency.

Mark a package as acceptable risk

To ignore an alert, reply with a comment starting with @SocketSecurity ignore followed by a space separated list of ecosystem/package-name@version specifiers. e.g. @SocketSecurity ignore npm/foo@1.0.0 or ignore all packages with @SocketSecurity ignore-all

  • @SocketSecurity ignore npm/object.assign@4.1.5
  • @SocketSecurity ignore npm/types-react-dom@19.0.0-rc.1
  • @SocketSecurity ignore npm/@nolyfill/is-core-module@1.0.39

Copy link

socket-security bot commented Dec 4, 2024

New and removed dependencies detected. Learn more about Socket for GitHub ↗︎

Package New capabilities Transitives Size Publisher
npm/@apollo/client@3.11.10 network Transitive: environment, eval +20 8.03 MB apollo-bot
npm/@faceless-ui/css-grid@1.2.1 None 0 36.3 kB jacobsfletch
npm/@faceless-ui/modal@2.0.2 Transitive: environment, eval +28 3.53 MB jacobsfletch
npm/@payloadcms/db-mongodb@3.0.2 environment, filesystem, network 0 475 kB elliotpayload
npm/@payloadcms/db-mongodb@3.2.2 environment, filesystem, network Transitive: shell +26 11.9 MB elliotpayload
npm/@payloadcms/email-nodemailer@3.0.2 None 0 20.7 kB elliotpayload
npm/@payloadcms/graphql@3.0.2 None 0 461 kB elliotpayload
npm/@payloadcms/graphql@3.2.2 None +4 1.27 MB elliotpayload
npm/@payloadcms/next@3.0.2 Transitive: environment +2 3.28 MB elliotpayload
npm/@payloadcms/next@3.2.2 Transitive: environment, filesystem, network, shell, unsafe +148 185 MB elliotpayload
npm/@payloadcms/plugin-cloud@3.0.2 environment, filesystem, network Transitive: shell +127 12.5 MB elliotpayload
npm/@payloadcms/plugin-form-builder@3.2.2 Transitive: environment, filesystem, network, unsafe +112 175 MB elliotpayload
npm/@payloadcms/richtext-lexical@3.0.2 environment +1 5.89 MB elliotpayload
npm/@payloadcms/richtext-lexical@3.2.2 environment Transitive: filesystem, network, unsafe +204 192 MB elliotpayload
npm/@payloadcms/ui@3.0.2 environment, network +2 10.6 MB elliotpayload
npm/@swc/core@1.9.2 None +1 195 kB kdy1, kwonoj
npm/@types/ejs@3.1.5 None 0 16.9 kB types
npm/@types/node@20.17.9 None +1 2.3 MB types
npm/cross-env@7.0.3 environment Transitive: filesystem, shell +6 76 kB kentcdodds
npm/dotenv@16.4.5 environment, filesystem 0 79.1 kB motdotla
npm/eslint-config-next@15.0.3 unsafe Transitive: environment, eval, filesystem +181 22 MB vercel-release-bot
npm/eslint@8.57.1 environment, filesystem Transitive: eval, shell, unsafe +98 10.8 MB eslintbot
npm/payload@3.2.2 environment, eval, filesystem, network, shell, unsafe +83 144 MB elliotpayload
npm/react-dom@19.0.0-rc-65a56d0e-20241020 environment +1 6.45 MB react-bot
npm/react-hook-form@7.53.2 None 0 912 kB bluebill1049
npm/react@19.0.0-rc-65a56d0e-20241020 environment 0 239 kB react-bot
npm/tsx@4.19.2 Transitive: filesystem +3 680 kB hirokiosame
npm/types-react-dom@19.0.0-rc.1 None 0 17.7 kB eps1lon
npm/types-react@19.0.0-rc.1 None +1 1.63 MB eps1lon
npm/typescript@5.5.2 None 0 21.9 MB typescript-bot

🚮 Removed packages: npm/@aws-sdk/client-cognito-identity@3.687.0, npm/@aws-sdk/client-s3@3.687.0, npm/@aws-sdk/credential-providers@3.687.0, npm/@aws-sdk/lib-storage@3.687.0, npm/@azure/abort-controller@1.1.0, npm/@azure/storage-blob@12.25.0, npm/@babel/cli@7.25.9, npm/@babel/core@7.26.0, npm/@babel/preset-env@7.26.0, npm/@babel/preset-react@7.25.9, npm/@babel/preset-typescript@7.26.0, npm/@clack/prompts@0.7.0, npm/@eslint/js@9.14.0, npm/@payloadcms/db-mongodb@3.4.0, npm/@payloadcms/next@3.4.0, npm/@payloadcms/payload-cloud@3.4.0, npm/@payloadcms/richtext-lexical@3.4.0, npm/@types/express@5.0.0, npm/express@4.21.1, npm/nodemon@3.1.7, npm/payload@3.4.0, npm/ts-node@10.9.2

View full report↗︎

@JarrodMFlesch JarrodMFlesch merged commit fa7ed3f into main Dec 4, 2024
53 checks passed
@JarrodMFlesch JarrodMFlesch deleted the fix/stale-useLocale-value branch December 4, 2024 19:00
Copy link
Contributor

github-actions bot commented Dec 6, 2024

🚀 This is included in version v3.5.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants