Trigger Rerender When Updating Array Using useEffect Hook
To update an array, best to spread the array into the new array.
const newBlogList = [ { blogTitle: 'test one', url: 'http://www.testone.com' }, { blogTitle: 'test two', url: 'http://www.testtwo.com' }]setBlogs(newBlogList) // option 1: does not trigger rerendersetBlogs([...newBlogList]) // option 2: triggers rerender
In option 1, react interpret the array as the same one.