I'm not trying to mutate the details. I just want to have access to this.props in the methods called in the constructor:
constructor(props){ super(props); this.props = props; // CAN I? There is no errors or warnings const filtered = this.filterValue(props.value); this.state = { value: filtered, } } filterValue(value){ // here I need this.props.* }
I know that there are several ways to do this, for example. an additional argument is passed to filterValue, however I want it to be as simple as possible. I think the above code is pretty intuitive, the question is: can I do it like this? React will override this.props anyway.
ecmascript-6 reactjs
cimak
source share