reactjs / reactjs/react.dev

How to create HOC for in built react component?

Open
#3,792 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
11.8k
Forks
7.9k
Avg merge
1d 11h
Merged PRs (30d)
11

Description

I am totally new to HOC.

I have one custom component where I am calling react in built component.
e.g suppose "ABC" is my custom component and "XYZ" react npm package installed in my project And I am importing "XYZ" in class "ABC".

Whatever I am passing to "XYZ" as props, I need to use it in custom "ABC" component. Is it possible with HOC??
e.g
...
import XYZ from "react npm package";
import ActionProvider from './ActionProvider';

class ABC extends React.Component{

 <XYZ  actionProvider={ActionProvider} />

}
export default ABC;
........
ActionProvider is simple js file(it is not a react component). I need to call 1 method from action provider in ABC. But not able to call. Making that method static will not solve my problem because I need to use this object the method which I want to call.

Help me out if anyone knows the solution.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

The issue names no repository file, test, or documentation entry point. First clarify whether a React HOC example or guidance about passing props and calling a method on ActionProvider is wanted; completion criteria are not specified.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, react
Domain
frontend
Issue type
Documentation
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
15/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.