Hello I have written a custom hook which pulls out the state management for a dialog. So basically it works like this:
const DialogHookExample = () => {
const ButtonComponent = useDialog(Button, DialogContent);
// ButtonComponent should
// have combined props of Button and DialogContent
return (
<div>
<ButtonComponent
dialogContentProps={{
header: 'Upload a file to import settings',
subheader: 'upload testing exists'
}}
variant="secondary" // should be spread onto DialogActionComponent
>
import
</ButtonComponent>
</div>
);
};
So you provide a component onto which you want to bind the onClick and you provide the Content of the dialog. You get back a component which accepts on the root level the props of the DialogActionComponent (the Button) and accept the props for the dialogContent as object.
The code works fine, however I am trying to type the hook generically so that the return component consists of the inferred types.