Skip to content

Conversation

@natterstefan
Copy link
Contributor

Feature

@tylerwolff
Copy link
Owner

Thanks for doing this! I'll get a release out soon

@tylerwolff tylerwolff merged commit 3736c3c into tylerwolff:master Oct 6, 2020
@tylerwolff
Copy link
Owner

@natterstefan v1.2.0 was released! https://www.npmjs.com/package/react-use-cookie let me know if you run into any issues

@natterstefan
Copy link
Contributor Author

I will, thanks @tylerwolff.

@chpio
Copy link

chpio commented Jun 7, 2021

This is still broken! It does not evaluate to the same result on the server & browser, breaking reacts hydration. On the server this returns initialValue, on a browser it returns the content of the cookie, but it has to return initialValue as well (at least for the first render obviously). Why not use the useEffect pattern?

@natterstefan
Copy link
Contributor Author

Hi @chpio,

you are right, that would resolve that issue effectively. I don't know why I missed that in the first place. I should've known that. 🤦‍♂️

Will you create a PR for that, as I am not using this in my current project anymore.

@chpio
Copy link

chpio commented Jun 7, 2021

hmm, i don't know, my change does not issue an update if another component sets the same cookie, see #15

chpio added a commit to chpio/useCookie that referenced this pull request Jun 9, 2021
* Removed `initialValue` argument (<tylerwolff#16 (comment)>)
* Fixed hydration mismatch between SSR & browser rendering (<tylerwolff#12 (comment)>)
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.

Server Side Rendering Support: ReferenceError: document is not defined

3 participants