johndatserakis / vue-cookie-accept-decline

👋 Show a banner with text, a decline button, and an accept button on your page. Remembers selection using cookies. Emits an event with current selection and on creation. Good for GDPR requirements.
https://johndatserakis.github.io/vue-cookie-accept-decline/
MIT License
147 stars 19 forks source link

Server-side rendering support #2

Closed matpeder closed 6 years ago

matpeder commented 6 years ago

The current implementation initializes the component on the created hook. I experienced initialization failed server-side in a non-browser environment (possibly because of lack of cookies etc.).

By deferring the initialization to the mounted hook (which never runs server-side) we can easily make sure no such issues happen.

This is a small change, which I hope makes sense.

johndatserakis commented 6 years ago

Cool - sounds good. I had it this way at first but moved to created to ensure everything had mounted before performing any actions. I think it should be fine this way, though - and the fact that it now can support ssr environments is a nice plus. Thanks for the pr!