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

window is not defined #2

Closed
nickyoung87 opened this issue Mar 25, 2022 · 2 comments · Fixed by #4
Closed

window is not defined #2

nickyoung87 opened this issue Mar 25, 2022 · 2 comments · Fixed by #4

Comments

@nickyoung87
Copy link
Contributor

I started getting this error when I refresh the page:

image

image

This is a next implementation and this is when running locally (haven't tested in a production environment) and it only happens when I do a hard refresh of the page. If I navigate to the page it works fine.

Any thoughts on this?

@nickyoung87
Copy link
Contributor Author

Alright I was finally able to revisit this issue and seem to have got a fix in place. I opened a PR but in case this repo is not managed I will supply my solution here as well.

What I did was just fork the repo and then pull the code from it and create my own ReactInputDateMask component inside my project.

image

I then edited the first line of the util.js to be this instead:
const ua = typeof window !== "undefined" ? window.navigator?.userAgent ?? "" : "";

That really is all there was to it. I did also convert it to a React functional component and did the export differently. I am not sure if that is necessary or not, so if it still gives you issues or doesn't work at all you may want to try that.

Hopefully this helps someone out there!

@elter1109
Copy link
Owner

hi @nickyoung87 , sorry for the long answer, unfortunately, at the moment I do not support this project, copying and correcting the code was a great solution, thank you

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 a pull request may close this issue.

2 participants