0

First of all I want to apologize for this dumb question, I'm a real beginner in webdev.

I'm trying to make a component of a clickable image that redirect us to another page of the website. I doesn't get any error but the image does not display (I have a ? on my webpage) and when I click on this "?" I'm not redirected at all.

Here is my component (in src/components/LinkPicture.js)

import { Link } from 'react-router-dom';

export default function LinkPicture(link, imgSrc) {
    return(
        <Link to={link}>
            <img src={imgSrc} />
        </Link>
    )
}

And here is my page component (in src/pages/intraje/Home.js, the image in src/assets/logo_SEIO_color_head.png)

import React from 'react'
import LinkPicture from '../../components/LinkPicture';
import logo from "../../assets/logo_SEIO_color_head.png"


const Home = () => {
    return (
        <div className='home'>
            <React.Fragment>
                <h1>Home</h1>
                <LinkPicture link={"intraje/profile"} imgSrc={logo}> </LinkPicture>
            </React.Fragment>
        </div>

    )
}

export default Home;

What are my errors ? thanks by advance :)

1
  • Wrap the props as following: export default function LinkPicture({link,imgSrc}) its a component with props and you are passing arguments Commented Oct 15, 2021 at 19:55

1 Answer 1

3
import { Link } from 'react-router-dom';

export default function LinkPicture({link, imgSrc}) { // modification here
    return(
        <Link to={link}>
            <img src={imgSrc} />
        </Link>
    )
}

now your props are passed.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.