Rematch: Unexpected token ','. Expected a ':' following the property name 'type'.

Created on 24 Mar 2018  路  4Comments  路  Source: rematch/rematch

Please help. What's wrong with my code.

My model :
export default { state : 0, reducers: { setToken : (state, payload) => state + payload } };

My action :
dispatch.auth.setToken(token)

The result is : "Unexpected token ','. Expected a ':' following the property name 'type'."
But if the code I change to be like this :
export default { state : 0, reducers: {} };
no error at all.

question

Most helpful comment

@kertul was this an android related issue?
If so, it should be resolved in the latest version.

All 4 comments

What does your init look like?

If you're exporting the model with default like in the example above, your init should look something like this:

models/auth.js

export default {
  state: 0,
  reducers: {
    setToken: (state, payload) => state + payload
  }
}

index.js

import { init } from '@rematch/core'
import auth from './models/auth'

const store = init({
  models: {
    auth: auth
  }
})

store.getState() // { auth: 0 }

Try to turn off "Debug JS Remotely" in emulator.

@kertul was this an android related issue?
If so, it should be resolved in the latest version.

I think this is due to an error during the installation, because when I create a new project and use the same code this problem does not appear.

I remember, this error occurred after I installed axios. Forgive me for being less thorough.

Was this page helpful?
0 / 5 - 0 ratings