Accessing context when calling confirm function
Maadtin opened this issue · comments
Martin Hernández Alvarado commented
Is there a way to access my app context from inside the ConfirmDialog from the example? it is returning an empty object when calling it :S
This is my Dialog
function ConfirmDialog(props) {
const theme = useTheme();
const {
show,
proceed,
confirmation,
options
} = props;
return (
<Modal onHide={() => proceed(false)} show={show}>
<div>{JSON.stringify(theme)}</div>
</Modal>
);
}
And this is the helper function that im calling:
function confirmDialog(message, options = {}) {
let confirm = createConfirmation(ConfirmDialog);
return confirm({confirmation: message, options});
}
The problem is that when calling this confirmDialog function my ConfirmDialog component cannot access the theme context and its throwing an error.
Thanks in advance !
KunihikoHarada commented
Hmm, I don't have any good solution about this. Since this library create another react tree, context can not be shared.