Click here to Skip to main content
15,880,392 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
call API using `fetch` and get response in console and assign values to table header.
after that creating one button in react js. Each button have one video URL which is got from API response 

API response:

    Group_Name: "Group_1"
    Video_Name: "http://localhost:4000/video/0"

    Group_Name: "Group_2"
    Video_Name: "http://localhost:4000/video/1"

I stored this response in `useState` and pass this usestate response to video player source 

            const actionButton = (params) => {
            setVideoName(response.videoName); //  How to update videoName here

            const [videoName, setVideoName] = useState([]);
            const [response, setResponse] = useState([]);

            headerName: "Actions",
            field: "Video_Name",
            cellRendererFramework: (params) => (
                  onClick={() => actionButton(params)}

Above code shows assign video_name to `Actions` header then I created one button. when I click one button, all of the videos open in one window and play all videos. But  I want it so that only that certain video that was clicked would show.

                {{ Video_Name }) => (

How to resolve this issue using react-hooks.

for more details and code reference 


how to create index for video and pass videos to video player source. when i click that button certain video that was clicked would show.


What I have tried:

I am trying to store API response in use state variable and pass it to button onclick action

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900