Search code examples
jsxtokenunexpected-token

How to solve an unexpected token?


I don't know why I have a problem with 'item'. I don't understand what it is about and how I can solve it.enter image description here

I tried with (_item), it doesn't work. I also tried to write // @ts-ignore in the previous line of code, but it doesn't work.


Solution

  • That li goes inside the braces of map function. Changing your code to something like this will fix the issue.

    ['home','about','work'].map((item) =>
      <li>{item}</li>
    );
    

    For more details, https://reactjs.org/docs/lists-and-keys.html