I have two react components parent and child. I need to pass a token from a child component to a parent. The child component is opened with window.open from the parent component. I cannot get a reference to the parent component and pass data to it from the child.
function Parent() {
return (
const SSOWindowOpen = () => {
const left = (screen.width - 465 ) / 2
const top = (screen.height - 650 ) / 4
const SSOWindow = window.open('/sso', 'SSOWindow',
'resizable=yes, width=' + 465
+ ', height=' + 650 + ', top='
+ top + ', left=' + left);)
}
child component
function children() {
return (
const Token = 123-token-123
window.opener ??????
)
}
You can declare a token variable in the parent window and from the child window you can assign it like:
`window.opener.variable_name=Token;`