-3

I am trying to make a website for my portfolio and I need some help.

What I want is the client to be able to click on one of pictures and select it and then to get redirected to another page with another options.

I think I should save the choice with a state, but I do not have the proper vision how to proceed. Can you help me or give me an idea?

<div className="landing_3">
        <p className="msg_2"> Customize the perfect gift</p>
        <p className="msg_3"> Choose one of the options to start with : </p>
        <div className="landing_3_items">
          <img alt="" src={c3} className="landing_img" />
          <img alt="" src={c4} className="landing_img" />
          <img alt="" src={c5} className="landing_img" />
        </div>
      </div>

Result of the code

ancyrweb
  • 1,220
  • 12
  • 12
  • You haven't posted any React code. You should add that as a [mcve]. Maybe [review the introductory documentation](https://reactjs.org/docs/getting-started.html). – Andy May 30 '22 at 17:53
  • If you're saving the starting option in some kind of local `useState`, note that navigating to a new page will lose the local state. Some solutions you can explore: Using React Context for global state, Using path/query parameter (for example: `/adventure/chocolate` or `/adventure?start=chocolate`) then use `useLocation` hook), or [passing data through React Router Link component](https://dev.to/medaminefh/passing-data-with-react-router-using-link-1h39), or [passing data through Route component](https://stackoverflow.com/q/45069824/14426823) – Bao Huynh Lam May 30 '22 at 18:01
  • Please provide enough code so others can better understand or reproduce the problem. – Community May 31 '22 at 01:34

1 Answers1

0

You can use the <Link> component from react-router-dom, like this :

<Link to="mypage">
    <img src="" />
</Link>

You need to make a router for your application too.

ancyrweb
  • 1,220
  • 12
  • 12
Daniel Roberto
  • 101
  • 1
  • 7