Can I use react-new-window to open multiple windows with URL
Ofer-Gal opened this issue · comments
I am having hard time with communicating from child React SPFx we part window to parent React SPFx we part
Will I be able to do this with react-new-window
? a button on the child should refresh the data in the parent.
Also, where can I see the code that if shows in the story board?
Thanks
I am having hard time with communicating from child React SPFx we part window to parent React SPFx we part
Will I be able to do this with react-new-window? a button on the child should refresh the data in the parent.
Yes, you can communicate from parent window to child.
import { useState } from "react";
import NewWindow from "react-new-window";
const Demo = ({ count }: { count: number }) => (
<NewWindow>
<h1>Hi 👋 {count}</h1>
</NewWindow>
);
function App() {
const [count, setCount] = useState(0);
const [open, setOpen] = useState(false);
return (
<div className="App">
<button onClick={() => setOpen(true)}>Open</button>
<button onClick={() => setCount(count + 1)}>
Increment count (count = {count})
</button>
{open && <Demo count={count} />}
</div>
);
}
export default App;
where can I see the code that if shows in the story board?
Definitely, that's an improvement I should address.
Assigning to myself to improve storybook.
I asked for "a button on the child should refresh the data in the parent" not from parent to child
I asked for "a button on the child should refresh the data in the parent" not from parent to child
I'm sorry for the misunderstanding. You can communicate from child to parent via callback similar to how components communicate in other scenarios. Here's an example (click on ChildParentComm
).
Thank you that helped