React Redux state re-render issues with object from mongodb

These are my codes for creating a new blog post:

import React, { useEffect, useState } from "react";
import { useDispatch, useSelector } from "react-redux";
import { useNavigate } from "react-router-dom";
import { createBlog, reset } from "../features/blogSlice";

const Createblog = () => {
   const dispatch = useDispatch();
   const [title, setTitle] = useState("");
   const [texts, setTexts] = useState("");
   const history = useNavigate();
   const { user, isError, isSuccess, message } = useSelector((state) => {
      return state.auth;
   });

   useEffect(() => {
      if (!user) {
         history("/login");
      }
      dispatch(reset());
   }, [user, isError, isSuccess, message, history, dispatch]);

   const handleSubmit = async (e) => {
      e.preventDefault();
      const data = {
         title,
         texts,
      };
      dispatch(createBlog(data));
      history("/");
   };

   return (
      <>
         <div className="container mt-3">
            <div className="row">
               <div className="col-3"></div>
               <div className="col-6 bg-info">
                  <h1>Create A New Blog</h1>
               </div>
               <div className="col-3"></div>
            </div>
            <div className="row">
               <div className="col-3"></div>
               <div className="col-6">
                  <form className="mt-3">
                     <input
                        type="text"
                        name="title"
                        className="form-control my-2"
                        placeholder="Type your Title"
                        onChange={(e) => setTitle(e.target.value)}
                     />
                     <textarea
                        name="texts"
                        className="form-control"
                        id="exampleFormControlTextarea1"
                        rows="10"
                        onChange={(e) => setTexts(e.target.value)}
                     ></textarea>
                     <button className="btn btn-primary col-6 my-2" onClick={handleSubmit}>
                        Click to post
                     </button>
                  </form>
               </div>
               <div className="col-3"></div>
            </div>
         </div>
      </>
   );
};

export default Createblog;

This is my redux slice for creating the Blog


import { createAsyncThunk, createSlice } from "@reduxjs/toolkit";
import blogService from "./blogService";

const initialState = {
   blogs: [],
   isError: false,
   isSuccess: false,
   isLoading: false,
   message: "",
};

export const createBlog = createAsyncThunk("blogs/createBlog", async (blogData, thunkAPI) => {
   try {
      const token = thunkAPI.getState().auth.user.token;
      return await blogService.createBlog(blogData, token);
   } catch (error) {
      const message = (error.response && error.response.data && error.response.data.message) || error.message || error.toString();
      return thunkAPI.rejectWithValue(message);
   }
});

export const getBlogs = createAsyncThunk("blogs/", async (_, thunkAPI) => {
   try {
      // const token = thunkAPI.getState().auth.user.token;
      return await blogService.getBlogs();
   } catch (error) {
      const message = (error.response && error.response.data && error.response.data.message) || error.message || error.toString();
      return thunkAPI.rejectWithValue(message);
   }
});

const blogSlice = createSlice({
   name: "blogs",
   initialState,
   reducers: {
      reset: (state) => {
         return initialState;
      },
   },
   extraReducers: (builder) => {
      // Get All Blogs
      builder
         .addCase(getBlogs.pending, (state) => {
            state.isLoading = true;
         })
         .addCase(getBlogs.fulfilled, (state, action) => {
            state.isLoading = false;
            state.isSuccess = true;
            state.blogs = action.payload;
         })
         .addCase(getBlogs.rejected, (state, action) => {
            state.isLoading = false;
            state.isError = true;
            state.message = action.payload;
         })

         // create blog
         .addCase(createBlog.pending, (state) => {
            state.isLoading = true;
         })
         .addCase(createBlog.fulfilled, (state, action) => {
            state.isLoading = false;
            state.isSuccess = true;
            state.blogs.push(action.payload);
         })
         .addCase(createBlog.rejected, (state, action) => {
            state.isLoading = false;
            state.isError = true;
            state.message = action.payload;
         });
   },
});

export const { reset } = blogSlice.actions;

export default blogSlice.reducer;


And, these are the redux blog service codes:

import Axios from "axios";

const api_Link = "http://localhost:8080/";

const createBlog = async (blogData, token) => {
   const config = {
      headers: {
         Authorization: `Bearer ${token}`,
      },
   };
   const response = await Axios.post(api_Link + `blog`, blogData, config);
   return response.data;
};

const getBlogs = async () => {
   const response = await Axios.get(api_Link);
   const data = response.data.data;

   return data;
};

const blogService = {
   createBlog,
   getBlogs,
};

export default blogService;

And, this is how I view the blog posts:

import React, { useEffect } from "react";
import { useDispatch, useSelector } from "react-redux";
import { useNavigate } from "react-router-dom";
import { getBlogs, reset } from "../features/blogSlice";

const Blogpage = () => {
   const dispatch = useDispatch();
   const history = useNavigate();
   const { blogs, isSuccess, isLoading, isError, message } = useSelector((state) => state.blogs);

   useEffect(() => {
      if (isError) {
         console.log(message);
      }

      dispatch(getBlogs());

      return () => {
         dispatch(reset());
      };
   }, [history, isError, message, dispatch]);
   return (
      <>
         <div className="container">
            <div className="row">
               <div className="col">
                  <h1 className="text-centr">Following are your blogs</h1>
               </div>
            </div>

            {blogs.map((item, sl) => {
               return (
                  <section className="bg-success text-light mt-4" key={sl}>
                     <div className="row">
                        <div className="col">
                           <h1 className="text-start">{item.title}</h1>
                           <h5 className="text-start bg-success text-light">Author: {item.creator.name}</h5>

                           <p className="text-start">{item.texts}</p>
                        </div>
                     </div>
                  </section>
               );
            })}
         </div>
      </>
   );
};

export default Blogpage;

Normally I can view the blog posts. Creating blog, redirecting everything works just fine. The problem occurs only when I try to retrieve anything from the creator field. Please see below. Here is what I get from db

{
    _id: new ObjectId("62b7a94583a09428b900a069"),
    date: 2022-06-26T00:33:09.838Z,
    title: 'This is title',
    texts: 'These are texts',
    creator: {
      _id: new ObjectId("62ae7514d2106b408c190667"),
      name: 'Md.Rashel',
      email: '[email protected]',
      
    }

Whenever I try to retrieve item.creator.name it shows this error : “Uncaught TypeError: Cannot read properties of undefined (reading ‘name’)”. But, once I reload the page, it works fine again.

I’m not sure how to fix this. I’m not also sure whether it is redux issue or react issue. Could you please help fix the issue? Thanks in advance.