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

Cookie consent render logic #1240

Merged
merged 2 commits into from
Nov 4, 2024

Conversation

hanbyul-here
Copy link
Collaborator

@hanbyul-here hanbyul-here commented Nov 4, 2024

This pr fixes infinite rerendering issue (it was from the parsing error of cookie value - so I added a unit test to make sure this works. - I used the solution from this post, feel free to edit if you see any improvement https://stackoverflow.com/questions/5142337/read-a-javascript-cookie-by-name) - also feel free to edit the test, I mainly put it for my dev purpose.

I removed currenwindowurl logic, replaced it with pathname passed from the layout root. I started making this change and then realized that this is not the cause of infinite rendering problem, but I think it is probably safer to depend on the pathname change than location.href since href can include so many things like query parameters?

Copy link

netlify bot commented Nov 4, 2024

Deploy Preview for veda-ui ready!

Name Link
🔨 Latest commit 7061657
🔍 Latest deploy log https://app.netlify.com/sites/veda-ui/deploys/672915c8b7a079000849bc0c
😎 Deploy Preview https://deploy-preview-1240--veda-ui.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@@ -56,6 +56,8 @@ function LayoutRoot(props: { children?: ReactNode }) {
const { children } = props;
const [sessionStart, setSesstionStart] = useState<string | undefined>();
const sessionItem = window.sessionStorage.getItem(SESSION_KEY);
const { pathname } = useLocation();
Copy link
Contributor

Choose a reason for hiding this comment

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

Im a fan of using useLocation but want to double check that this isn't going to cause a problem when implemented in NEXT.js?

Copy link
Collaborator Author

@hanbyul-here hanbyul-here Nov 4, 2024

Choose a reason for hiding this comment

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

yes, thanks for checking. We are not going to export layout root for library. This is where things that are unique to instances should happen. (ex. routing for Next is not using react-router-dom, but Single Page Application like our current instances will use react-router-dom.)

@snmln snmln merged commit 0b1a732 into 1171-Cookie-Consent---Clean-up Nov 4, 2024
9 checks passed
@snmln snmln deleted the cookie-consent-render-logic branch November 4, 2024 19:58
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