1.

What is a high order component in React Native?

Answer»

Just now, we have learned what high order functions are in Javascript and what are its benefits. With that KNOWLEDGE, we can easily guess what a high order component will be and how it would be a GOOD practise to use high order components wherever we can. Since components are also functions which are called as component in React world so High order components are components which take either component as an argument or RETURNS another component. Higher order components are JavaScript functions used for adding additional functionalities to the existing component. 

These components are the pure component which means it doesn’t know any side effect. Its output is totally based on the input values. For example, connect function from a react-redux library is also a high order component. Connect takes mapStateToProps and MAPDISPATCHTOPROPS as an argument and returns a new component which can ACCESS redix store. The withProvider function of react-redux, the withRouter function of react-router are very well used function which is also an example of high order component.



Discussion

No Comment Found