score:1
Accepted answer
the argument for your higher-order component is the class (or function) for the component that you want to wrap, not an instance of that component.
what you want to do is create a new component by applying the hoc to the wrapped/inner component. this should happen outside of render() because it should only happen once and not on every re-render.
const fetchablesubreddits = withfetch(subreddits);
then inside your render you can use this like any other jsx component.
<fetchablesubreddits someprop={somevalue} />
Source: stackoverflow.com
Related Query
- Error writing my first HOF react component: This may happen if you return a return a Component instead of <Component />
- Error : Functions are not valid as a React child. This may happen if you return a Component instead of <Component /> from render
- Functions are not valid as a React child. This may happen if you return a Component instead of from render
- React - Functions are not valid as a React child. This may happen if you return a Component instead of <Component /> from render
- React - Warning: Functions are not valid as a React child. This may happen if you return a Component instead of <Component /> from render
- React is showing "Functions are not valid as a React child. This may happen if you return a Component instead of <Component /> from render"
- Functions are not valid as a React child. This may happen if you return a Component instead of <Component /> from render
- Functions are not valid as a React child. This may happen if you return a Component instead of <Component> from render
- React Warning: Functions are not valid as a React child. This may happen if you return a Component instead of <Component /> from render
- Functions are not valid as a React child. This may happen if you return a Component instead of <Component /> from render. in react v6
- React Auth0 (Functions are not valid as a React child. This may happen if you return a Component instead of <Component /> )
- Warning: Functions are not valid as a React child. This may happen if you return a Component instead of <Component />
- Warning: Functions are not valid as a React child.This may happen if you return a Component instead of <Component /> from render
- You may need an appropriate loader to handle this file type: arrow function in react component
- Why this error is showing: "A valid React element (or null) must be returned. You may have returned undefined"
- Uncaught Error: Rendered fewer hooks than expected. This may be caused by an accidental early return statement in React Hooks
- how to solve this error You may need an appropriate loader to handle this file type
- React with NextJS and Next-CSS: You may need an appropriate loader to handle this file type
- Why I am getting this error message when I run react js project first time in my system?
- React - Module parse failed: Unexpected Token. You may need an appropriate loader to handle this file type
- The component styled...has been created dynamically. You may see this warning because you've called styled inside another component
- bind(): You are binding a component method to the component. React does this for you automatically?
- ReactJS error You may need an appropriate loader to handle this file type
- Why does this React component return the string '0'
- React JS: Rendered fewer hooks than expected. This may be caused by an accidental early return statement
- React / Webpack - "Module parse failed: Unexpected token - You may need an appropriate loader to handle this file type."
- Error "Maximum update depth exceeded. This can happen when a component calls setState inside useEffect"
- ERROR in ./src/index.js 14:4 Module parse failed: Unexpected token (14:4) You may need an appropriate loader to handle this file type
- Webpack ERROR - You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file
- Error: data.map is not a function. This error throws whenever I run react component
More Query from same tag
- Azure App Service Getting error while deploying REACT JS application
- web worker not loading properly when using typescript on nextjs
- Need help to make a event handler to work properly in react js
- Showing elements based on authentication status in ReactJS
- Webpack and programmatically injected content scripts
- How can I get value from react modal bootstrap?
- MUI DataGrid Error: TypeError: Cannot read properties of undefined (reading 'MuiDataGrid')
- React-Native another VirtualizedList-backed container
- Why is onClick function being called upon Render in one situation but not the other situation
- react state not working as it is supposed
- Error on clicking the LinkedIn Share Button on IE/Edge
- Display different data from json file, depending on link clicked
- New to React: Why is one array treated differently than the other?
- Redux Action not returning JSON?
- React throws CORs errors when moving recaptch ready callback
- webpack not generating bundle.js
- update state from ajax call on componentdidmount -react
- Formik validate initial values on page load
- nginx sub_filter module not working with REACT websites
- Update item in state onClick ReactJS
- How to get height of an element at each page update
- How to select group based checkbox antd in reactjs
- How to develop Reusable Bootstrap-like Components
- Importing Ant Design Component doesn't work
- Async/Await not executing as expected
- Media query on SearchIcon not working. Material-UI, React
- Typescript map array of objects giving error: property '(property)' does not exist on type object
- UseState bug in React
- How to force a React component containing a growing HTML table to stay within the intended maximum dimensions?
- Can't loop elements when using an external library : Type 'Element[]' is not assignable to type 'string'