In the console I'm getting two outputs , one with empty array and another one with the updated array . I only need the updated array after the component did mount function.. How can I eliminate the first one...
class App extends Component {
state={
categories:[]
};
componentDidMount() {
axios.get(`https://s3.ap-south-1.amazonaws.com/scapic-others/json/models.json`)
.then(response => {
this.setState({categories:response.data.categories });
})
};
render() {
return (
<div className="App">
<header className="App-header">
<img src={logo} className="App-logo" alt="logo" /></header>
<h1 className="shake-opacity shake-freeze">3D models</h1>
{console.log(this.state.categories)}
</header>
<footer className="pv4 ph3 ph5-m ph6-l red">
<small className="f6 db tc">© 2018 <b className="ttu">Scapic Inc</b>., All Rights Reserved</small>
<div className="tc mt3">
{`Made by Renjith`}
</div>
</footer>
</div>
);
}
}
export default App;