1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

chakra uiを使用して、ボタンにハンバーガーアイコンを埋め込もうとしましたが、 TypeErrorが出てしまう

Posted at

はじめに

chakra uiを使用して、ボタンにハンバーガーアイコンを埋め込もうとしましたが、
TypeErrorが出てしまう

問題

下記のように @chakra-ui/icons からimportしているのにも関わらず、「TypeError」が出る。

Header.tsx
import { HamburgerIcon } from "@chakra-ui/icons";
import { Box, Flex, Heading, IconButton } from "@chakra-ui/react";
...

export const Header: FC = memo(() => {
return (
//...
    <IconButton aria-label="メニューボタン" size="sm">
       <HamburgerIcon />
    </IconButton>
  )
});

image.png

解決方法

公式ドキュメントによると、v3から chakra-ui/iconsは削除されたとのこと。

image.png

代わりに react-icons/faFaBars を使用。

import { FaBars } from "react-icons/fa";

<IconButton aria-label="メニューボタン" size="sm">
    <FaBars />
</IconButton>

無事、アイコンを表示することができました。

image.png

おわりに

文法やインストールしたパッケージに問題ないのに、エラーが出る場合は公式ドキュメントを疑うことが大事。

1
1
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
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?