rmariuzzo / react-new-window

🔲 Pop new windows in React, using `window.open`.
https://rmariuzzo.github.io/react-new-window/
MIT License
442 stars 107 forks source link

closeOnUnmount props not founded #147

Closed deqrios closed 1 year ago

deqrios commented 1 year ago

I use version 1.0.1, but not founded closeOnUnmount props. here my project dependences.

 "dependencies": {
    "@craco/craco": "^7.0.0",
    "@emotion/babel-preset-css-prop": "^11.10.0",
    "@emotion/react": "^11.10.5",
    "@emotion/styled": "^11.10.5",
    "@testing-library/jest-dom": "^5.16.5",
    "@testing-library/react": "^13.4.0",
    "@testing-library/user-event": "^13.5.0",
    "@types/jest": "^27.5.2",
    "@types/lodash": "^4.14.189",
    "@types/node": "^16.18.3",
    "@types/react": "^18.0.25",
    "@types/react-chartjs-2": "^2.5.7",
    "@types/react-dom": "^18.0.8",
    "@types/react-router-dom": "^5.3.3",
    "ag-grid-community": "^28.2.1",
    "ag-grid-react": "^28.2.1",
    "antd": "^4.24.2",
    "axios": "^1.1.3",
    "chart.js": "^4.0.1",
    "chartjs-adapter-moment": "^1.0.1",
    "chartjs-plugin-zoom": "^2.0.0",
    "craco-less": "^2.0.0",
    "http-proxy-middleware": "^2.0.6",
    "lodash": "^4.17.21",
    "moment": "^2.29.4",
    "react": "^18.2.0",
    "react-chartjs-2": "^5.0.1",
    "react-dom": "^18.2.0",
    "react-new-window": "^1.0.1",
    "react-router-dom": "^6.4.3",
    "react-scripts": "5.0.1",
    "typescript": "^4.8.4",
    "valtio": "^1.7.5",
    "web-vitals": "^2.1.4"
  },

and i checked library types in module. i not founded closeOnUnmount types. here library code. node_modules/react-new-window/types/NewWindow.d.ts

import React from 'react'
import ReactDOM from 'react-dom'

declare module 'react-new-window' {
  type EventHandler = () => void
  type OpenEventHandler = (window: Window) => void

  /**
   * Base features common to all window features.
   *
   * @remarks These will be concatenated into a string for window.open.
   */
  export interface IWindowFeatures {
    height?: number
    width?: number
    [i: string]: boolean | number | string
  }

  /**
   * Props for opening a new window.
   *
   * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/open
   */
  export interface INewWindowProps {
    /**
     * Children to render in the new window.
     */
    children?: React.ReactNode

    /**
     * The URL to open, if specified any children will be overriden.
     */
    url?: string

    /**
     * The name of the window.
     */
    name?: string

    /**
     * The title of the new window document.
     */
    title?: string

    /**
     * The set of window features.
     */
    features?: IWindowFeatures

    /**
     * A function to be triggered before the new window unload.
     */
    onBlock?: EventHandler | null

    /**
     * A function to be triggered when the new window could not be opened.
     */
    onUnload?: EventHandler | null

    /**
     * A function to be triggered when the new window opened.
     */
    onOpen?: OpenEventHandler | null

    /**
     * Indicate how to center the new window.
     */
    center?: 'parent' | 'screen'

    /**
     * If specified, copy styles from parent window's document.
     */
    copyStyles?: boolean
  }

  export default class NewWindow extends React.PureComponent<INewWindowProps> {
    private readonly container: HTMLDivElement
    private window: Window | null
    private windowCheckerInterval: number | null
    private released: boolean

    /**
     * Release the new window and anything that was bound to it.
     */
    public release(): void
  }
}

i tried version 1.0.0. but not founded too. I want to know why I can't use it.

LucasLemanowicz commented 1 year ago

The PR that added closeOnUnmount was merged into main after 1.0.1 was released:

Screen Shot 2023-01-24 at 4 10 37 PM

@rmariuzzo - could you please release a 1.0.2?

rmariuzzo commented 1 year ago

Ok, I will try to do this in the next hours.

deqrios commented 1 year ago

@LucasLemanowicz Thanks a lot! I will try it.