0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

React 波括弧が認識されない

Posted at

Array.map関数を使ってイテレータからコンポーネントを生成しようとした時の備忘録。

コード

App.tsx
export default function App() {
    return (
        <Box>
            {
                keys.map( key => (
                    <Button>{ key }</Button>
                ));
            }
        </Box>
    )
}

エラー

Unexpected token 'Box'. Expected JSX identifier
(このエラー、<Box>自体ではなくその子要素の文法が間違っている時に出てきて分かりづらい)

解決

不必要な;を外す

App.tsx
// --snip--
<Box>
    {
        keys.map( key => (
            <Button>{ key }</Button>
        )) // ここにあったコンマを外す
    }
</Box>
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?