refactor: use react-use

simplify imports as tree shaking works
This commit is contained in:
EnixCoda 2020-03-15 02:04:15 +08:00
parent 588940bed3
commit 58a63bc77b
No known key found for this signature in database
GPG key ID: 0C1A07377913A1DD
4 changed files with 3 additions and 13 deletions

View file

@ -7,11 +7,10 @@ import { connect } from 'driver/connect'
import { FileExplorerCore } from 'driver/core'
import { ConnectorState, Props } from 'driver/core/FileExplorer'
import * as React from 'react'
import useEvent from 'react-use/esm/useEvent'
import { useEvent, usePrevious } from 'react-use'
import { FixedSizeList as List, ListChildComponentProps, ListProps } from 'react-window'
import { cx } from 'utils/cx'
import { useOnLocationChange } from 'utils/hooks/useOnLocationChange'
import { usePrevious } from 'utils/hooks/usePrevious'
import { getCurrentPath } from 'utils/URLHelper'
import { TreeNode, VisibleNodes } from 'utils/VisibleNodesGenerator'
import { Icon } from './Icon'

View file

@ -11,7 +11,7 @@ import { SideBarCore } from 'driver/core'
import { ConnectorState, Props } from 'driver/core/SideBar'
import { oauth } from 'env'
import * as React from 'react'
import useEvent from 'react-use/esm/useEvent'
import { useEvent } from 'react-use'
import { cx } from 'utils/cx'
import * as DOMHelper from 'utils/DOMHelper'
import { JSONRequest, parseURLSearch } from 'utils/general'

View file

@ -1,5 +1,5 @@
import * as React from 'react'
import useLocation from 'react-use/esm/useLocation'
import { useLocation } from 'react-use'
export function useOnLocationChange(
callback: React.EffectCallback,

View file

@ -1,9 +0,0 @@
import * as React from 'react'
export function usePrevious<T>(newValue: T) {
const previousRef = React.useRef(newValue)
React.useEffect(() => {
previousRef.current = newValue
})
return previousRef.current
}