The problem of introducing mobx into react

  1. how to design store in mobx? If you use mobx, do you want to use react"s state? or not?
  2. write the operation of the form, make changes when each field needs to add a change method, feel more tedious, is there a better way?
  3. can you provide some mobx best practices in your project?
Feb.21,2022

you can probably give up these ( mobx , redux ).

local state can be implemented with state .

global, such as login information, topics, etc., can be implemented

with context . The

question says that "each field needs to add a change method", which can be implemented in the following ways

//
set = (type) => (ev) => {
    this.setState({
        [type]:ev.target.value
    })
}
//...
<input onchange={this.set('name')} />
<input onchange={this.set('age')} />
<input onchange={this.set('loaction')} />
<input onchange={this.set('company')} />
....
Menu