I have a .js file that contains an array that will be imported as data. For example, it will look like this:
const ideasData = [
    {
        content:"Content",
        title: "This Title",
        date: new Date()
    },
    {
        content:"content2",
        title: "second title",
        date: new Date()
    }
]
export default ideasData
The export is necessary since I will import the data in another file. I use the data in the program and then will modify it throughout.
import ideasData from "./ideasData";
class Ideas extends Component{
    constructor() {
        super()
        this.state = {
            ideas : ideasData
        }}}
I want to overwrite the data in the file in a similar format(the array, then the export) every couple seconds as an autosave. So next time I open the webpage it will look like when it was closed.
I put a function autoSave() in the class and then setInterval(this.autoSave, 5000) in the render method before the return. I am not sure how to save the array, this.state.ideas to the ideasData file. Also, I am not sure about putting the setInterval in the render method. I changed it to setInterval(console.log("saved"),5000) and it seems to have only logged that in the console once. 
 
    