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

Updating to 1.02 throws console error #21

Closed
eripoll opened this issue Jul 31, 2020 · 5 comments
Closed

Updating to 1.02 throws console error #21

eripoll opened this issue Jul 31, 2020 · 5 comments
Labels
bug Something isn't working

Comments

@eripoll
Copy link

eripoll commented Jul 31, 2020

Version

@nuxtjs/color-mode: 1.0.2
nuxt: 2.13.3

Reproduction Link

Steps to reproduce

I just updated to 1.0.2, with no other change and my app now throws

[Vue warn]: data functions should return an object:
https://vuejs.org/v2/guide/components.html#data-Must-Be-a-Function
(found in <Root>)

What is Expected?

No error ;)

Side note:
Using 1.0.0 with nuxjs 2.13.3 in SPA mode, when generating and starting, I get the following error

TypeError: Cannot read property 'preference' of undefined
    at be (app.460976a.js:1)
    at app.460976a.js:1
    at f (vendors~app.23ddfa9.js:2)
    at Generator._invoke (vendors~app.23ddfa9.js:2)
    at Generator.O.forEach.e.<computed> [as next] (vendors~app.23ddfa9.js:2)
    at r (app.c57ce17.js:2)
    at l (app.c57ce17.js:2)
@eripoll eripoll added the bug Something isn't working label Jul 31, 2020
@eripoll
Copy link
Author

eripoll commented Jul 31, 2020

Ok so I updated to Nuxtjs 2.14.0 and color 1.0.2
I still have the warning and
yarn build + yarn start as an SPA still throws the same error on start up:

TypeError: Cannot read property 'preference' of undefined
    at be (app.250609e.js:1)
    at app.250609e.js:1
    at h (vendors~app.761da66.js:2)
    at Generator._invoke (vendors~app.761da66.js:2)
    at Generator.next (vendors~app.761da66.js:2)
    at r (app.a5226ce.js:2)
    at l (app.a5226ce.js:2)

FIY 1.0.0 doesn't throw the "[Vue warn]: data functions should return an object:
https://vuejs.org/v2/guide/components.html#data-Must-Be-a-Function
(found in )" warning but still throws the "Cannot read property 'preference' of undefined" when building.

Any clue what could be happening since everything is a-OK when yarn dev and I didn't have any issue beforehand?

@rankjie
Copy link

rankjie commented Aug 1, 2020

ctx.nuxtState.colorMode is undefined on my dev environment (macOS 10.15.6, nuxt 2.14.0, SPA mode)
This commit caused the bug and changing themes is not working in 1.0.2.
Revert this part fixed everything for me. 7a873ab#diff-58e6cb97fd6582c2fdc3e79032ce4070L13-L1


Update 1:
Cause: nuxtState is available only in universal mode, which makes ctx.nuxtState.colorMode undefined in SPA mode.

@eripoll
Copy link
Author

eripoll commented Aug 2, 2020

@rankjie I applied your patch and I am able to select Theme on 1.02, thanks!

However, when building (yarn build) and starting (yarn start), I still have my app crashing with the
Cannot read property 'preference' of undefined
error.

Do you see the same issue? Any idea on how to fix that?

@atinux atinux closed this as completed in b92d64b Aug 4, 2020
@atinux
Copy link
Contributor

atinux commented Aug 4, 2020

Really sorry about this, I forgot the SPA mode 🤦

I just releases v1.0.3 to fix this regression.

@hut-a-massmediagroup-100
Copy link

hut-a-massmediagroup-100 commented Sep 9, 2020

@atinux, i have the same problem. please check my issue - #25

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants