way of pushing to url according to id

Viewed 50

new react hooks(typescript) developer here, could somebody suggest on how to implement this: when user has chosen from select option(antd) then that should take one to that specific option what he chose (id?) with this?:

                  history.push(`/info/${....id}`); ??

or using Link

my code :

import React, { useState } from "react";
import "antd/dist/antd.css";
import { Select } from "antd";
import { useHistory, useRouteMatch } from "react-router-dom";   

function EventsSection() {
    const { Option } = Select;
    const history = useHistory();
    const anarray = [
    { name: "obama", address: "usa", id: "81" },
    { name: "obama", address: "usa", id: "86" },
    { name: "putin", address: "russia", id: "91" },
    { name: "erdogan", address: "turkey", id: "31" },
    { name: "jebordoq", address: "alien", id: "29" },
  ];

  return (
    <section>
    

      <Select
        className="senderId"
        style={{ width: "100%" }}
        placeholder="Hide Me"
        open={true}
        listHeight={350}
      >
        {anarray.map((item, idx) => (
          <Option
            style={{ width: "100%", height: "100%" }}
            className="options"
            key={idx}
            value={item.id}
          >
            {item.name}
            <br></br>
            {item.address}
            <br></br>
          </Option>
        ))}
      </Select>
    </section>
  );
}

export default EventsSection;

ask me if needed

0 Answers
Related