TanvirMahin24 / winbox-react

This package is the react version of Winbox.js
15 stars 5 forks source link

Multiple windows in loading while initializing the package #4

Open santhoshsvkmm opened 2 years ago

santhoshsvkmm commented 2 years ago

The code samples are given below

import React from 'react'; import './App.css'; import WinboxReact from 'winbox-react' import 'winbox-react/dist/index.css' function App() { const [options,setOptions] = React.useState() const [show, setShow] = React.useState(true) React.useEffect(()=>{ setOptions({ title: 'Custom Title', border: '4', width: "500px", height: "300px" }) },[show]) return ( <> {show && ( <WinboxReact {...options}>

Lorem ipsum dolor sit amet

  </WinboxReact>
)}</>

); }

export default App;

Screenshot Screenshot 2021-12-29 002221

TanvirMahin24 commented 2 years ago

React.useEffect(()=>{ setOptions({ title: 'Custom Title', border: '4', width: "500px", height: "300px" }) },[show]) In this code you are re-rendering the page multiple times which is causing the multiple winbox. You do not need the useEffect Hook. Please follow the Documentation