flowbite icon indicating copy to clipboard operation
flowbite copied to clipboard

event listener is not added

Open damirqa opened this issue 3 years ago • 1 comments

Describe the bug I have an App Component, authentication takes place inside it. If the user is authorized, we output Dashboard, otherwise Authentication.

Dashboard has a Navbar, and it has a button that shows a modal window. But this button doesn't work because the EventListener is missing.

If you skip authentication and display Dashboard, the button works and the modal window opens.

dont work

`function App() { const {verifyAuthentication} = useActions() const authData = useTypedSelector(state => state.auth) const [status, setStatus] = useState('no') const [auth, setAuth] = useState(false)

if (localStorage.getItem('token') && !auth) {
    verifyAuthentication()
    setAuth(true) // todo fix
}

useEffect(() => {
    if (authData.loading && !authData.authResponse) setStatus('loading')
    if (!authData.loading && authData.authResponse?.user) setStatus('yes')
    if (!authData.loading && !authData.authResponse) setStatus('no')
}, [authData])

if (status === 'loading') return <FullWindowSpinner/>
if (status === 'yes')     return <Dashboard/>
if (status === 'no')      return <Authentication/>

}`

if i change to

return <Dashboard/>

modal window open

i used this example

when i try const modal = new Modal(document.getElementById('defaultModal'), null).show();

i got error

Uncaught ReferenceError: Modal is not defined

damirqa avatar Apr 17 '22 10:04 damirqa