Why can't the compiler read addMore imported from '../addMore/addMore'?
P粉463824410
P粉463824410 2023-08-17 15:20:19
0
1
554
<p>I want to add a component 'addMore', but the compiler doesn't recognize it. What did I miss? please help. </p> <p><br /></p> <pre class="brush:js;toolbar:false;">import React from 'react' import { MdDeleteForever } from 'react-icons/md' import addMore from '../addMore/addMore' import './ShoppingCardItem.css' export default function ShoppingCardItem() { return ( <div className='shoppingCardItem-Container'> <img src="./img/Apfel.jpg" alt="" /> <p>2x Apfel</p> <addMore /> <MdDeleteForever /> </div> ) }</pre> <p><br /></p> <p><br /></p> <pre class="brush:js;toolbar:false;">import React from 'react' export default function addMore() { return ( <div className="btn-group"> <button type="button" className="btn btn-primary"> </button> <button type="button" className="btn btn-primary">-</button> </div> ) }</pre> <p><br /></p>
P粉463824410
P粉463824410

reply all(1)
P粉358281574

Component names must start with uppercase letters. Rename the file name addMore.jsx to AddMore.jsx and also change the import path. To view this information please visit React.dev Functional Components

// ShoppingCardItem.jsx

import React from 'react'
import { MdDeleteForever } from 'react-icons/md'
import AddMorefrom '../AddMore/AddMore'
import './ShoppingCardItem.css'


export default function ShoppingCardItem() {

  return (
    <div className='shoppingCardItem-Container'>
        <img src="./img/Apfel.jpg" alt="" />
        <p>2x Apfel</p>
        <AddMore/>
        <MdDeleteForever />
        
    </div>
  )
}
// AddMore.jsx

import React from 'react'

export default function AddMore() {
  return (
    <div className="btn-group">
        <button type="button" className="btn btn-primary">+</button>
        <button type="button" className="btn btn-primary">-</button>
    </div>
  )
}
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template