score:-1
i'm not sure you are using hoc in the right way, ref (https://reactjs.org/docs/higher-order-components.html)
in hoc, you pass a component in and the hoc provides additional props and/or rendered components:
const withlocale = (component, locale, ...otherprops) => {
if (!locale) {
return <error statuscode={404} />
}
return (
<localeprovider lang={locale}>
<component {...otherprops} />
</localeprovider>
)
}
const wrappedpage = ({prop1, prop2}) => <h1>{prop1 + ' ' + prop2}</h1>
export default withlocale(wrappedpage, locale, prop1, prop2 etc)
Source: stackoverflow.com
Related Query
- getStaticProps in HOC not working in Next.js
- NextJS: getStaticProps revalidate not working
- Why is my favicon not working in my next js app?
- Prev and Next button is not working correctly at the breakpoints
- Next JS - getStaticProps not returning anything
- styled-components withTheme HOC not working with types React.FC
- Animate presence not working in next js for exit animations only?
- Component does not receive props from getStaticProps when wrapped with HOC
- Axios custom instance not working properly with next JS
- Next Js dynamic imports with no SSR not working
- Exit animation not working in next js framer motion?
- React HOC working on some but not other components
- React Router / Redux / HOC not working with 'render' prop
- Next.js, getStaticProps not working with component but does with page
- Creating custom pagination, but next and prev buttons are not working
- Material UI snackbars not working properly in Next JS
- React HOC callback not working with default props
- nextjs getStaticProps not working in my component
- Next.JS getstaticprops revalidate not working
- getStaticProps not working if the page is requested from cmd (not browser)
- React Router - Path with :id is not working correctly for component wrapped by HOC
- Next and previous buttons not working properly
- Jsonwebtoken verify next function not working in middleware
- Material table next page not working when i click it
- Why is my dynamic title not working in next js
- React-router-dom redirect not working with withRouter HOC (react-redux)
- Context Provider not working in Next with Typescript
- Not working Server side rendering Styled-Components with Next JS
- Why is the callback function not working in the HOC component?
- React Next app not working as expected, most likely hook updating issue
More Query from same tag
- React-hook-form conditional validation of text field, based on if another checkbox is checked?
- How can I place images dynamically in Tailwind CSS
- make yield put blocking in redux react
- React Functional component with Typescript: Typescript does not understand changing property types
- Pie Chart not rendering React Chart.js
- React application freezes using custom async/await function
- How to properly fetch data from several API calls and display it to the DOM in React
- My submit function responds with Bad Gateway 502
- React-Admin, autocomplete Forms by onChange event
- Does React use server-side-rendering or client-side-rendering?
- D3+javascript+react : Cant add a label to edge (link)
- Error object in the client side not showing the error message
- Display MONGODB data in React.js page
- React - How can I set my parent state using child component, using function structures (not classes)
- ReactJs Create Reusable component with multiple different children
- CSS not changing when using React Router to route to another component
- How to add coordinates to google-maps-react on a user click event?
- Hide popper of one field when opening popper of another field
- ReactNative: TypeError: this.props.navigation.navigate is not a function
- TypeError: Cannot read property 'error' and TypeError: Failed to fetch
- React Fetch Request returning data is undefined
- react and node js serving from single port endpoint not found
- Passing value from callback in component to another component
- React Formik: IsSubmitting not working for me
- How to fix unique "key" prop in ReactJS table?
- Not able to add todo in a todo-list using react and redux. What am I doing wrong?
- How can I pass props to base component in styled-component?
- Reactjs router onEnter hook authentication cause infinite loop
- Calling async method in React functional component
- Applying className/onClick/onChange not working on Custom React Component