Skip to content

Commit

Permalink
remove early return
Browse files Browse the repository at this point in the history
  • Loading branch information
thoomasbro committed Feb 16, 2023
1 parent 5024333 commit 5ba09d4
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions frontend/src/features/SideWindow/SideWindowLauncher.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useForceUpdate } from '@mtes-mct/monitor-ui'
import { useEffect, useRef } from 'react'
import { MutableRefObject, useEffect, useRef } from 'react'
import { StyleSheetManager } from 'styled-components'

import { SideWindow } from '.'
Expand All @@ -9,17 +9,12 @@ import { sideWindowActions } from './slice'

export function SideWindowLauncher() {
const dispatch = useAppDispatch()
const newWindowRef = useRef<HTMLDivElement | null>(null)
const newWindowRef = useRef() as MutableRefObject<HTMLDivElement>
const { forceUpdate } = useForceUpdate()
useEffect(() => {
forceUpdate()
}, [forceUpdate])

// First, let's generate the right ref before passing it to <StyleSheetManager />
if (!newWindowRef.current) {
return <SideWindow ref={newWindowRef} />
}

return (
<StyleSheetManager target={newWindowRef.current}>
<LegacyNewWindow
Expand Down

0 comments on commit 5ba09d4

Please sign in to comment.