28

React.js WHY WONT THE F%#&ING STATE CHANGE????

3hours later you realize you forgot curlybrackets...

Comments
  • 0
    Don't use state... Embrace pure functional programming! 😂😝
  • 0
    @timos functional programming in an oop language.. no thanks 🤢

    Although I'm sure there's a library for that 😉
  • 1
    Hail haskell and golang
  • 1
    I'm new to React, but what really helps me to prevent this kind of errors and time wastes to happen is a linter. If you use atom go for "eslint" and the Airbnb config for it.
    It would have had recognized the missing curly and shown you the error. :)
  • 0
    It gets better by time (new react come over here 🙏)
  • 0
    Yes a not so good idea I believe... But what about this:
    https://github.com/purescript-contr...
    @brod 😀😂
  • 0
    Hail Haskell indeed!!! Simplicity and reasoning really easy.
    @setuid0
  • 1
    @Sirhennihau I'm not new to react and I'm using eslint but it wont notice the error in this case. I have a fields object in state i i.e
    fields = {
    password: ""
    newPassword: ""
    etc
    }

    Then in an let's say onInputChange method you have a variable fields object where you insert all the input values and then you are about to set the state: this.setState(fields) this wont give you any any errors either in react or eslint since fields already is an object, and it will actually update the state, it will jus set the values outside of thw fields object in state and what is missing is the wrapping curlybrackets which are fairly hard to spot. Easy to find the issue during troubbleshooting though, but I was a bit tiered in this scenario :P
  • 1
    @JohanG2012

    Ah okay that makes sense. :P
Add Comment