Questions tagged [high-order-component]
83 questions
60
votes
1 answer
Purpose of Array "Join" function in Swift
What is the use of join() in arrays?
In other languages, it is used to join elements of array into string. For example,
Ruby Array.join
I've asked some question about join() in
Swift Array join EXC_BAD_ACCESS

Kostiantyn Koval
- 8,407
- 1
- 45
- 58
11
votes
2 answers
How to connect redux to a none default component
I have a file with multi component that I want to export and connect all to redux, how can I do this?
Connect wrapper need to export default, but I have multi component.

Mohsen
- 1,415
- 1
- 13
- 26
9
votes
1 answer
Higher Order React Component for Click Tracking
I'd like to implement a higher order react component which can be used to easily track events (like a click) on any React component. The purpose of this is to easily hook clicks (and other events) into our first party analytics tracker.
The…

jamis0n
- 3,610
- 8
- 34
- 50
7
votes
5 answers
Pass dynamic value to HOC in react
I write some HOC and I need to pass to this HOC a dynamic object that I create on some life cycle level and I did not get him as a prop.
If I try to pass some static value ( for example initialize myObj from start) it works as expected and I get the…

OriEng
- 1,424
- 18
- 34
7
votes
1 answer
Access children of react element
Imagine having React component
function List() {
return (
- 1
- 2

STO
- 10,390
- 8
- 32
- 32
6
votes
3 answers
Displaying the Sum of values in React JSX
Im trying to add up all of the calories in my array thats stored in the state.
id: shortid.generate(),
text: this.state.text,
calorie: this.state.calorie
This is the data structure that being stored in the state array meals
Im currently…

Saul
- 311
- 1
- 2
- 10
5
votes
1 answer
Context API HOC Unit testing
I have a HOC component which wraps React's context API as follows
import React from 'react';
import { AppContext } from './Context';
export function withAppContext(Component) {
return function WrapperComponent(props) {
return (
…

Gagan
- 5,416
- 13
- 58
- 86
4
votes
1 answer
Material-UI makeStyles vs withStyles generated class names
I've noticed that classes generated with makeStyles and the use of hooks follow this nomenclature:
while the classes generated with withStyles and the use of HOC follow this one:
Is there a way to use makeStyles (I like to use hooks) but keep the…

GoncaloNGT
- 375
- 1
- 16
4
votes
1 answer
Flow requires type annotation of props in HOC
I'm struggling with types of injected props by HOC.
It's just simple, in App Component, there are two props: title and message.
However title is provided by HOC.
Here's the code for this:
/* @flow */
import React, { Component } from 'react';
import…

modernator
- 4,341
- 12
- 47
- 76
3
votes
1 answer
3
votes
2 answers
Error: Objects are not valid as a React child (found: object with keys {$$typeof, type, compare, WrappedComponent, displayName})
When i enter my React Router-dom i point my routes to a validation page.
In event aim loged in or not, i push my route(history) to required page but i keep getting bellow error.
Error: Objects are not valid as a React child (found: object with keys…

Mbanda
- 968
- 11
- 21
3
votes
1 answer
Transform Loading HOC to use Hooks and avoid react navigation problem
I have made a HOC for showing a loading modal when my component is loading.
export const withLoading = (Component) => {
return function HOCLoading(props) {
const [isLoading, setIsLoading] = useState(false)
return (
…

Vencovsky
- 28,550
- 17
- 109
- 176
3
votes
1 answer
Refactor HOC as hook
during my time spent on react and on several articles I'm asking to my self how to refactor an HOC as hook, and if it would be usefull and why,
This is a little component to refactor
function withSpacing(Component) {
const WrappedWithSpacing =…

Legeo
- 784
- 4
- 20
- 44
3
votes
1 answer
React: how to properly type the HOC component?
I searched around the suggestions but could not find any answer.
I'm basically think that I can properly type the HOC as follows:
This is my component at the moment:
// @flow
import React, { Component } from 'react';
import moment from…

drifterOcean19
- 372
- 5
- 24
2
votes
1 answer
Are there any relevant use case for React Render Props and HOC with functional components?
I know it's possible to use RRP and HOC patterns with functional components, my question actually is, are there any point on doing that? Making some researches I read React/Custom Hooks can essentially handle what render props did in the past with…

AmodeusR
- 33
- 5