본문 바로가기
개발일지/React

[React 리액트] react-new-window 라이브러리 - 새로운 window창 띄우는 방법

by jungwonyu 2022. 12. 28.
728x90

📌 설치

npm i react-new-window --save

 

📌 예시 코드

import React from 'react'
import NewWindow from 'react-new-window'

const Demo = () => (
  <NewWindow>
    <h1>Hi 👋</h1>
  </NewWindow>
)

 

📌 내 코드

        <NewWindow
            title="title입력"
            center="screen"
            features={{
                width: 1200,
                height: 900,
            }}
            onOpen={() => onOpen}
        >
            <PrivacyPolicy />
        </NewWindow>

NewWindow를 클릭하면  <PrivacyPolicy /> 컴포넌트를 띄우도록 구현했다.

 

 

🔗 참고

react-popout 이라는 라이브러리도 있다.

❗ 데모 확인하기

http://jake.ginnivan.net/react-popout/

 

Document

 

jake.ginnivan.net


🔗 출처

https://www.npmjs.com/package/react-new-window

 

react-new-window

Pop a new window in React, using window.open API. Latest version: 1.0.1, last published: 2 months ago. Start using react-new-window in your project by running `npm i react-new-window`. There are 21 other projects in the npm registry using react-new-window.

www.npmjs.com

https://github.com/JakeGinnivan/react-popout

 

GitHub - JakeGinnivan/react-popout: React popout is a React component wrapping window.open allowing you to host content in a bro

React popout is a React component wrapping window.open allowing you to host content in a browser popup window. - GitHub - JakeGinnivan/react-popout: React popout is a React component wrapping windo...

github.com