Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

React Component is not appearing

I am trying to use my custom component but its not appearing. What I am doing wrong?

Custom Component code:

import React, { Component } from 'react'

export class cardComp extends Component {
    render() {
        return (
            <div>
                <h1>My Custom Component</h1>
            </div>
        )
    }
}

export default cardComp

and the class where I am trying to use it

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

import React from 'react'

import { cardComp } from 'src/components/cardComp'

const Daily = () => {
    // console.log(kpiData)

 return (
        <>


           <div><cardComp /></div>
        </>
    )
}

export default Daily

Also, it says cardComp is declared but never used.

>Solution :

I am not sure why you added a bracket.
Please remove that and try like this

import cardComp from 'src/components/cardComp';

Also, I would like to suggest first letter is better capitalized for the component.

For instance CardComp instead of cardComp.
Hope this is helpful to you.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading