Uaxe is here! We recently launched a UI/UX Design Agency

Check Uaxe
React v16.3.0 Context API
May
9
2018
9 May 2018

React v 16.3.0 Release : New Context API Features

With time React is introducing rich features, which makes developer’s work easy. Most developers like me are waiting for this kind of update from the React community. Here is with the blossoming of reacting React introducing one rich feature called Context API.

In React application Many times happens that developers need to pass data from top-bottom or vice-versa to communicate with the same data in multiple components to fulfill that requirement react introduce context API. Previously and in some cases now, to communicate between multiple components with data or function developers uses props but in this case, it’s necessary to pass from multiple layers.

When can context API be used?
Context API’s main purpose is to share data globally between multiple components for the Component tree in react. It can be used for setting user auth, theme or any multiple language setup in React application. The main focus of context API is to make easy data sharing between multiple components and reuse it in a more easy way.

Note :- The old context API won’t break all future releases of React 16.x, so there is sufficient time to migrate applications.

CreateRef API
In the first phases, React has two ways to implement refs, 1) string ref API 2) callback API. among both string API is referred by most developers but the official document refers to the callback API.

Note: callback API support will be continued in upcoming releases
Learn more about the new createRef API here.

ForwardRef API
Higher-order components (or HOCs) are commonly hot favourite concepts nowadays used to share data among multiple components and reuse code. or we can define HOC as it takes one component as argument and return new components with shared function and data.