I have an App component that has a state containing a property "faces" , which is initialised after an object
const initFaces = { left : [[0,0,0],[0,0,0],[0,0,0]], front : [[1,1,1],[1,1,1],[1,1,1]], right : [[2,2,2],[2,2,2],[2,2,2]], back : [[3,3,3],[3,3,3],[3,3,3]], up : [[4,4,4],[4,4,4],[4,4,4]], down : [[5,5,5],[5,5,5],[5,5,5]] }; class App extends React.component{ ... this.state = { faces : initFaces } ... } now my app is constantly changing the state of the "faces" property so i tried implementing a button to revert it back to the original state . This is what i have :
this.setState({ faces : initFaces }) But this doesnt work , and this does :
this.setState({ faces : { left : [[0,0,0],[0,0,0],[0,0,0]], front : [[1,1,1],[1,1,1],[1,1,1]], right : [[2,2,2],[2,2,2],[2,2,2]], back : [[3,3,3],[3,3,3],[3,3,3]], up : [[4,4,4],[4,4,4],[4,4,4]], down : [[5,5,5],[5,5,5],[5,5,5]] } }) Why does it not work simply by referencing the object that has the identical content that i just copied inside of it ?