0

I need to import "Item" and i used that;

import Item from './Item' But there is a "Attempted import error" mistake => Attempted import error: './Item' does not contain a default export (imported as 'Item'). I added the "Item" under the header class;

 </Header>
  <Items>
  {items.map(item=>(<Item></Item>)
  )}
  </Items>
Ahmet
  • 9
  • 1

2 Answers2

0

Your Item component does not export any default code use something like import {Item} from './Item or inside ITem File use something like export default ITem you can read more import-export

Moufeed Juboqji
  • 690
  • 4
  • 11
0

You must export the Item component that you can import the Item component elsewhere. A example:

Item.js:

function Item() {
    return (
        <div>
            // Item stuff
        </div>
    )
}
    
export default Item;

Note: the important here is the export default Item;. So that you can import the Item component in other components with import Item from './ItemPath';. Of course you must set the right path to your Item component.

Example.js:

import Item from './ItemPath';

function Example() {
    return (
        <div>
            </Header>
            <Items>
            { items.map((item) => (
                <Item>Some item</Item>
            )}
            </Items>
         </div>
    )
}
Marci
  • 302
  • 5
  • 12