Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot open the same window more than once #74

Open
wangyfax opened this issue Nov 24, 2020 · 1 comment
Open

Cannot open the same window more than once #74

wangyfax opened this issue Nov 24, 2020 · 1 comment

Comments

@wangyfax
Copy link

It should click on the same place many times as you would on a browser, and multiple windows will be opened. However, it seems that this function is not supported at present. Or maybe there is something wrong with my usage?

@JoaquimEsteves
Copy link

Hello, I was facing the same problem but I managed to sort myself out with the onUnload prop.

Example of a component that opens any number of windows onclick and retains their data.

const TestMultiple = () => {
  const [windows, setWindows] = React.useState<null[]>([]);
  const [otherWindowInput, setInput] = React.useState('');
  return (
    <>
      <p>Here's the input from another window</p>
      <p>{otherWindowInput}</p>
      <button onClick={() => setWindows((prev) => [...prev, null])}>Click me to open a new window! Wowsers</button>
      {windows.map((_) => (
        <NewWindow onUnload={() => setWindows((prev) => prev.slice(1))}>
          <h1>WOW</h1> <input onChange={(e) => setInput(e.target.value)}></input>
        </NewWindow>
      ))}
    </>
  );
};

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants