Jestem nowy w bibliotece React.js i przeglądałem kilka samouczków i natknąłem się na:
this.setStatethis.replaceState
Podany opis nie jest zbyt jasny (IMO).
setState is done to 'set' the state of a value, even if its already set
in the 'getInitialState' function.
Podobnie,
The replaceState() method is for when you want to clear out the values
already in state, and add new ones.
Próbowałem je this.setState({data: someArray});śledzić, this.replaceState({test: someArray});a następnie console.logged je i stwierdziłem, że stateteraz mam zarówno datai test.
Następnie spróbowałem this.setState({data: someArray});śledzić je, this.setState({test: someArray});a następnie console.logged je i stwierdziłem, że stateznowu mam oba datai test.
Więc jaka dokładnie jest różnica między tymi dwoma?