Using Higher Order Components in a React Application

  • If you have started using ReactJS recently often you might have felt that you are performing repeated logic in many components.
  • Well Higher Order Component (HOC) provides solution to such a kind of problems.
  • A function (Functional component in React) which takes a component and gives back another component.
  • So the exact benefits are:

    Functional components started from React V15.

  • But apart from that if we are careful enough we can have an architecture which can abstract logic that can be shared across other presentational components using HOC has great benefits.

If you have started using ReactJS recently often you might have felt that you are performing repeated logic in many components. For example consider an app having:
Continue reading “Using Higher Order Components in a React Application”

A gentle Introduction to Higher Order Components

A gentle Introduction to Higher Order Components:  by @rwieruch #JavaScript #ReactJS

  • I want to pick out one use case, the conditional rendering with higher order components, to give you two outcomes from this article as a reader.
  • First, it should teach you about higher order components with the use case of conditional rendering.
  • Keep in mind, that altering the look of a component with a higher order component, specifically in the context of conditional rendering, is only one of several use cases to use HOCs.
  • In order to teach higher order components, the article focuses on the use case of conditional rendering.
  • Now you could use the higher order component but with a function that determines the conditional rendering.

Higher order components, or known under the abbreviation HOCs, are often a hard to grasp pattern in React. The article gives you an introduction to HOCs, how to use them elegantly in the case of conditional rendering and how to abstract them…
Continue reading “A gentle Introduction to Higher Order Components”

A gentle Introduction to Higher Order Components

  • I want to pick out one use case, the conditional rendering with higher order components, to give you two outcomes from this article as a reader.
  • First, it should teach you about higher order components with the use case of conditional rendering.
  • Keep in mind, that altering the look of a component with a higher order component, specifically in the context of conditional rendering, is only one of several use cases to use HOCs.
  • In order to teach higher order components, the article focuses on the use case of conditional rendering.
  • Now you could use the higher order component but with a function that determines the conditional rendering.

Higher order components, or known under the abbreviation HOCs, are often a hard to grasp pattern in React. The article gives you an introduction to HOCs, how to use them elegantly in the case of conditional rendering and how to abstract them…
Continue reading “A gentle Introduction to Higher Order Components”

Lazy Loaded React Components With Webpack 2

Lazy Loaded #reactjs Components With #webpack 2

  • How to improve your React code-base with higher order components (HOC) and how to make parts of your single page application load on-demand with Webpack 2.
  • Because Webpack searches the code for and creates new chunks depending on the path argument.
  • We the file needs to look like this:

    Now is able to create our wrapping component (WC) and give it access to the function that will load the right import.

  • The promise will resolve to our loaded module and this should export a React component as default.
  • When default export, the real component (RC) we really want to render is stored in the state of the WC, the WC will render again, this time with the RC and pass its down to it, so the parent of WC won’t be the wiser about what happened.

Making components load on-demand with Webpack 2.
Continue reading “Lazy Loaded React Components With Webpack 2”

Lazy Loaded React Components With Webpack 2

Lazy loaded #ReactJS components with #Webpack 2:

  • How to improve your React code-base with higher order components (HOC) and how to make parts of your single page application load on-demand with Webpack 2.
  • Because Webpack searches the code for and creates new chunks depending on the path argument.
  • We the file needs to look like this:

    Now is able to create our wrapping component (WC) and give it access to the function that will load the right import.

  • The promise will resolve to our loaded module and this should export a React component as default.
  • When default export, the real component (RC) we really want to render is stored in the state of the WC, the WC will render again, this time with the RC and pass its down to it, so the parent of WC won’t be the wiser about what happened.

Making components load on-demand with Webpack 2.
Continue reading “Lazy Loaded React Components With Webpack 2”

All the Conditional Renderings in React

  • When a component has conditional rendering, the instance of the rendered component can have different looks.
  • The ternary operation makes the conditional rendering in React more concise than the if-else statement.
  • You can use a switch case operator to handle the conditional rendering of these multiple states.
  • Higher order components (HOCs) are a perfect match for conditional rendering in React.
  • They add control components to enable conditional renderings without JavaScript in JSX.

The article is an exhaustive list of conditional renderings in React. But what is conditional rendering in React? In a conditional render a component decides based on one or several conditions which elements it will return…
Continue reading “All the Conditional Renderings in React”

ReactJS App Architecture – Xourse – Medium

ReactJS App Architecture  #javascript

  • The Request Module runs an ajax asynchronous function to the OData Services, they respond with a JSON object which is passed back to the UI ReactJS component by the Request Module after being sorted, filtered and converted to an immutableJS object.
  • Then the UI ReactJS component updates the state and re-renders itself to be presented to the user with all the information obtained by the request.
  • The containers provide the UI components with the state and actions they can perform.
  • The ReduxJS store receives actions from the UI ReactJS components, these actions contain the information passed to the Reducers.
  • The UI ReactJS component is calling a get function defined at the Request Module, this functions contains the modularity to work will all the forms and organizing the data to make the request (making a very useful single functions to get data dynamically).

Hi, in this post I’ll be presenting you the front end architecture behind a ReactJS App with ReduxJS for state management. This is a very popular combination these days and the one we have invested…
Continue reading “ReactJS App Architecture – Xourse – Medium”