In use effect function, after calling an API,we used the useState function to set the value but when we printing the console.log then it prints "null".It means the value of state_data not set.When I render the state_data ,it showing me a error as shown below .
import React, { useEffect, useState } from 'react';
import Navbar from '../Home/Header/Header';
import 'bootstrap/dist/css/bootstrap.min.css';
import Header from '../Home/Header/Header';
import { Button, Card, Col, Container, Row, Spinner, Table } from 'react-bootstrap';
import Chart from "react-google-charts";
import Trackers from './Trackers';
import Charts from './Charts';
import Tables from './Tables';
import Carousels from './Carousels';
import Axios from 'axios';
import './Covid_Update.css';
function Covid_Update() {
  const [state_data,set_state_data]=React.useState(null);
  useEffect(() => {
    Axios.get("https://api.covid19india.org/data.json").then(function (val) {
    set_state_data(val.data["statewise"]);
    console.log(state_data);   
   
  })
  },[])
  return (
    <>
      { 
      state_data==null?<Container id="load"><center><Spinner animation="grow" variant="dark" size="100" /></center></Container>:<div>
      {state_data}
      </div>
            }
    </>
  );
}
export default Covid_Update;
Error: Objects are not valid as a React child (found: object with keys {}). If you meant to render a collection of children, use an array instead.
    in Covid_Update (created by Context.Consumer)
    in Route (at App.js:17)
    in Switch (at App.js:14)
    in Router (created by BrowserRouter)
    in BrowserRouter (at App.js:12)
    in main (at App.js:11)
    in App (at src/index.js:9)
    in StrictMode (at src/index.js:8)
Please Help me out!!!
 
    