Questions tagged [react-hoc]

Use this tag when you have questions regarding the HOC techinque, commonly used with React to enrich existing components with additional behaviour.

HOC, abbreviation for higher order component is a technique commonly used in the ReactJS library, usually to enrich another component's behaviour, for example, by passing to it additional data or functions via props. Usually this enrichment happens by using a helper function (HOC function) which takes as one of its parameters an existing component's type and returns the new, enriched component. A very popular example of HOC usage is the connect function in react-redux library to provide a component with pieces of redux state.

63 questions
0
votes
1 answer

How to perform multiple queries with Apollo graphql HOC?

I'm writing a web app and I need to query Apollo's local state as well as remote API. Apollo graphql HOC does not allow to send multiple queries but offers some compose function. But it seems that @apollo/react-hoc package does not have it.…
0
votes
1 answer

How to wrap a class in a higher order component?

I was wondering if I can wrap a class component inside a hoc that has also a class. import React, { Component } from "react"; import { View } from "react-native"; import { Toast } from "react-native-easy-toast"; const withToast = EnhancedComponent…
Bojke
  • 646
  • 1
  • 6
  • 21
-1
votes
2 answers

How to properly use HOC with Hooks?

What is the best way to use HOC if I need to get data from a hook? I have two options: Pass the received data from the hook as a parameter to the HOC HOC: export const withAuth = ( isAuth: boolean, { ComponentForAuthorized, …
Maiddragon
  • 19
  • 1
  • 4
1 2 3 4
5