MCPcopy Create free account
hub / github.com/codemistic/Web-Development / componentDidMount

Function componentDidMount

react-NewsMonkey/src/components/News.js:29–40  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

27
28 //componentDidMount always runs after render method
29async componentDidMount(){
30 //console.log("cdm");
31 let url=`https://newsapi.org/v2/top-headlines?country=in&category=${this.props.category}&apiKey=f31900ddb83a4b52bf702e1fe7089003&pageSize=${this.props.pagesize}`;
32 this.setState({loading:true});//During the time the api is fetching the data then only spinner will be there which will show loading
33 let data=await fetch(url);
34 let parsedData=await data.json();
35 console.log(parsedData);
36 this.setState({articles: parsedData.articles,
37 totalResults: parsedData.totalResults,
38 loading:false
39 });
40}
41
42handlePrevclick=async()=>{
43 console.log("Previous");

Callers

nothing calls this directly

Calls 1

logMethod · 0.45

Tested by

no test coverage detected