An Interest In:
Web News this Week
- April 19, 2024
- April 18, 2024
- April 17, 2024
- April 16, 2024
- April 15, 2024
- April 14, 2024
- April 13, 2024
July 17, 2022 05:41 pm GMT
Original Link: https://dev.to/hamsof/substring-function-in-react-5daa
?Error in Substring function in react
I am getting data from an API specifically a string. But that string too large. I want to reduce it to only 15 letter.
So
function Banner() { const [movie,setMovie] = useState([]) useEffect( () =>{ async function fetchData(){ const req = await axios.get("some API request")//req is a string for sure setMovie(req) } fetchData(); },[])const desciption = movie.substring(0,15)return(<h1> {desciption} </h1>)
It render for the first time but on reload it throughs error every time I reload that substring is not defined
Original Link: https://dev.to/hamsof/substring-function-in-react-5daa
Share this article:
Tweet
View Full Article
Dev To
An online community for sharing and discovering great ideas, having debates, and making friendsMore About this Source Visit Dev To