React uses Flux architecture and it is said in https://reactjs.org/docs/thinking-in-react.html that React has two models - state
and props
. And there are some suggestions for model management in React https://reactjs.org/community/model-management.html - but all of this seems to some additional layers to enhance the Flux. The big questions to which I am seeking the answers are:
- Should I define model classes in React? I.e. if I have Customer class notion, then I can: 1) define the attributes of Customer directly as the attributes of
state/props
2) define the attributes of Customer as the attributes ofstate.customer/props.customer
; 3) define some JavaScript template/classCustomer
separately and simply say, thatstate.customer/props.customer
is of typeCustomer
and don't repeat attributes in thestate/props
. I feel, that 3) is the right approach, isn't it? - If 3rd options (of the previous point) is the right approach, then how can I define the
Customer
template and how can I define thatstate.customer/props.customer
is of this template? I could use those template in some serialization, some model validation tasks as well and I could use in ReactNative project as well.