Skip to content

Instantly share code, notes, and snippets.

@Lahirutech
Created January 29, 2023 10:22
Show Gist options
  • Save Lahirutech/311f4a349957a2ddd5aae122b5d9cb19 to your computer and use it in GitHub Desktop.
Save Lahirutech/311f4a349957a2ddd5aae122b5d9cb19 to your computer and use it in GitHub Desktop.
import React from 'react';
const withNewProp = (WrappedComponent) => {
const [count, setCount] = React.useState(0);
return (props) => {
return (
<WrappedComponent
{...props}
newProp='add many props'
count={count}
setCount={setCount}
/>
);
};
};
const MyComponent = (props) => {
return (
<div>
{props.newProp}+ {props.count}
</div>
);
};
const EnhancedMyComponent = withNewProp(MyComponent);
export default EnhancedMyComponent;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment