I have to fetch data from an API and display it as a list, and then when you click on an item in the list it should take you to another page with details about that item. I don't know how to make the li element take me to another page with details
This is my app.js
import React, { useState, useEffect } from "react";
import CharacterList from "./Components/CharacterList";
import Navbar from "./Components/Navbar";
function App() {
const [characters, setCharacters] = useState([]);
const callBreakingBadAPI = async () => {
const url = `https://www.breakingbadapi.com/api/characters?name`;
const resp = await fetch(url);
const data = await resp.json();
setCharacters(data);
};
useEffect(() => {
callBreakingBadAPI();
}, []);
return (
<div className="container">
<Navbar />
{<CharacterList characters={characters} />}
</div>
);
}
export default App;
this is characterList.js
import React from "react";
import CharacterListItem from "./CharacterListItem";
const CharacterList = ({ characters }) => {
return (
<section>
{characters.map((character) => (
<CharacterListItem character={character} key={character.char_id} />
))}
</section>
);
};
export default CharacterList;
And this is my CharacterListItem.JS
import React from "react";
const CharacterListItem = ({ character }) => {
return (
<ul>
<li>Name: {character.name}</li>
</ul>
);
};
export default CharacterListItem;
I have a characterinfo folder inside my components folder with characterInfo.js where I want to switch to show details about the clicked item.