2

On my react app I'm receiving this error: SCRIPT1028: Expected identifier, string or number

It seems to come from my Store.js with easy-peasy


const store = createStore({
  answers: [],
  totalPoints: 0,
  otp: "",
  loading: false,

  addAnswer: action((state, payload) => {
    const prevState = state.answers;
    const newAnswers = _.unionBy([payload], prevState, "questionNumber");

    return (state = {
      answers: newAnswers,
      totalPoints: _.sumBy(newAnswers, "selectedAnswer"),
      otp: state.otp,
    });
  }),

//**error seems to come here**
  setOtp: action((state, payload) => {
    return { ...state, ...state.answers, ...{ otp: payload } };
  }),

  setLoading: action((state, payload) => {
    return {
      ...state,
      ...state.answers,
      ...{ otp: state.otp },
      ...{ loading: payload },
    };
  }),
});

export default store;
  • Have you tried in other browsers like Chrome and Firefox to see if there's the same error? The code you provide is not enough to reproduce the issue. Please provide [a minimal code snippet](https://stackoverflow.com/help/minimal-reproducible-example) which can **run and reproduce** the issue. – Yu Zhou Feb 07 '22 at 05:18

0 Answers0