hamburger-react icon indicating copy to clipboard operation
hamburger-react copied to clipboard

Default import not working

Open im-calvin opened this issue 1 year ago • 4 comments

Just had a really weird bug I want to document. I was using the import as expected:

import Hamburger from "hamburger-react";

and for some reason I was running into this issue, Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: object. which means that my import wasn't right.

Super weird since the default import is already specified and it works in development, but it fails when I run npm run build

If I change the import to import {Squash as Hamburger} from 'hamburger-react';, it works again.

im-calvin avatar Jan 11 '24 07:01 im-calvin

@im-calvin Can you provide more info about your dev environment? Do you use Next.js or any another framework/library? You Node.js version etc.

cyntler avatar Jan 28 '24 22:01 cyntler

I'm using Astro and React with npm and node version 18.14.1

im-calvin avatar Jan 28 '24 23:01 im-calvin

@im-calvin I also had a problem with the default-exported Hamburger, and importing the concrete kind of it (I used Squash) resolved it – now I can't reproduce it after a quick attempt to get back to the default import, but my problem was related to React, and I had a wrapper component for the Hamburger using the Astro-React integration

didnotwant avatar May 17 '24 06:05 didnotwant

@didnotwant

I think then the problem might be to do with Astro/react and the way that it handles dependency bundles? I'm not 100% certain but it seems likely

im-calvin avatar May 17 '24 14:05 im-calvin