Home > Blockchain >  TypeError: Invalid attempt to destructure non-iterable instance. On React Native
TypeError: Invalid attempt to destructure non-iterable instance. On React Native

Time:03-01

I am getting an error because of this line const [guesses, setGuesses] = React.useState < IGuess > defaultGuess; On Vscode it shows Operator '>' cannot be applied to types 'boolean' and 'IGuess'.ts(2365)

****
interface IGuess {
  [key: number]: string;
}

const defaultGuess: IGuess = {
  0: '',
  1: '',
  2: '',
  3: '',
  4: '',
  5: '',
};

export default function App() {
  const [guesses, setGuesses] = React.useState < IGuess > defaultGuess;
*****

CodePudding user response:

You need to change to this
const [guesses, setGuesses] = React.useState (defaultGuess)

  • Related