score:5
Accepted answer
// @flow
import React, { Component } from 'react';
import type { ComponentType } from 'react';
type Props = {
x: string | void, // <<== HERE
}
const withReferral = <PassedProps: {}>(
WrappedComponent: ComponentType<PassedProps>
): ComponentType<$Diff<PassedProps, Props>> => {
class withReferral extends Component<PassedProps> {
render() {
return (<WrappedComponent {...this.props} x={'test'} />);
}
}
return withReferral;
};
export default withReferral;
Source: stackoverflow.com
Related Query
- Flowtype: Typehinting class based HOC component
- Typescript with React - use HOC on a generic component class
- Class based component vs Functional components what is the difference ( Reactjs )
- How to implement Drag and Drop in Class based Component in react-dnd
- How can I convert popover MATERIAL-UI functional component to class based component?
- Converting a class based component to hooks (gapi API)
- React HOC has a Typescript error as a class component but not as a function component
- How to convert const reactjs component to class based
- Not able to add, update, delete rows in material table react using class based component. Previously it was working with functional component
- Using dispatch in class based component give error of invalid hook call
- Conversion of functional components in react into class based component
- Why would this HOC class not return a rendered child component in React?
- How to use a HOC with a class Component
- passing data from a react based component to vanilla js class
- How to add class in a common Header component based on the redux data
- value of this inside the eventHandler in class based component
- Get wrapped component class from connected HOC in react-redux
- Consuming React useContext in a class based component in TypeSCript
- Converting React class based component to functional component
- Converting an ES6 hook based app to Class Based component
- How to use ownProps on a Class Based Component (react-redux)
- React - Update state in class component based on text inputted by user after button click
- react-router-dom conditionally build routes and pass parameters to class based component
- Class based component has ref warning of functional component
- How to convert class based component into function based component?
- Event handling: functional based component vs class based component
- ReactJS | Change function Component into Class based one for ref error
- How to call returned const from a react function in a class based component
- Error messages when removing hooks from class component - Role Based Access Nav Bar
- React.js: How to convert class based component to functional?
More Query from same tag
- Combining tap to dismiss keyboard, keyboard avoiding view, and submit button
- Calling action from another action
- Issue with component array filter
- (node:20732) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future in nodejs
- Getting a "this.setState is not a function" error
- Am I missing some code to view this video in a react app using visual studio code [react]
- How spy mock function in object props when tests with jest?
- What does <T> in javascript for?
- Why is this object failing my own PropTypes validation
- debounce react-jsonschema-form validate function
- i got error from console while making loginPage but i don't know what's wrong (React.js)
- React JS infinite loop on redux sagas
- Variable storage update across react component
- How Can I Destructure error from is RTK Query Mutation Hook?
- React JS Uncaught Reference Error: function not defined
- Pointers on how to use leaflet's polyline in reactjs & react-leaflet
- Is it safe to edit same piece of state with two dispatches in a row
- how to set ref in list of items react js?
- CSS - You may need an appropriate loader to handle this file type
- Group and sum of an array of objects based on number key
- Query data is received but can not be accessed from GraphQL API
- How to pass password value to wordpress using POST in JSON User API
- Reactjs - Rendering login component
- React don't remember firebase state Error this.setState is not a function
- Importing web3 causing a problem in react js
- Dynamically created array length in reactJS
- onClick on <li> does't trigger
- Appending array of items to array of items in React state
- Render Images in tic tac toe app using reactjs
- How to use UseEffect cleaning on async function for Firebase Login?