React / higher-order components

The controlled components

In HTML, form elements (such as <input><textarea> , and  <select>) form elements, are typically maintain their state , and updated based on user input. However react, the state of the components are maintained in state, the controlled components means that react by internal state (state) of the control assembly (form elements), the value of the state value change form is also changed, the controlled components must match onchange method (and no two-way data binding vue).

Higher-order functions

Higher order function is a function receiving as parameters to a function or as a function of the output return.
 
Higher-order components

Higher order components are the parameters for the component , the return value is the new component to function .

Components are converted to props UI, high order component is converted to another component assembly.

HOC does not modify the incoming assembly , it will not use inheritance to copy their behavior. Instead, HOC assembly by packing in a container component to the composition of new components . HOC is a pure function , no side effects.

 

Guess you like

Origin www.cnblogs.com/liang-meng/p/11803039.html