Replace react-hotkeys-hook with react-hotkeys
This commit is contained in:
+20
-11
@@ -1,7 +1,8 @@
|
||||
import React from 'react'
|
||||
import { useSelector } from 'react-redux'
|
||||
import { Layout } from 'react-admin'
|
||||
import React, { useCallback } from 'react'
|
||||
import { useDispatch, useSelector } from 'react-redux'
|
||||
import { Layout, toggleSidebar } from 'react-admin'
|
||||
import { makeStyles } from '@material-ui/core/styles'
|
||||
import { HotKeys } from 'react-hotkeys'
|
||||
import Menu from './Menu'
|
||||
import AppBar from './AppBar'
|
||||
import Notification from './Notification'
|
||||
@@ -15,15 +16,23 @@ export default (props) => {
|
||||
const theme = useSelector((state) => themes[state.theme] || themes.DarkTheme)
|
||||
const queue = useSelector((state) => state.queue)
|
||||
const classes = useStyles({ addPadding: queue.queue.length > 0 })
|
||||
const dispatch = useDispatch()
|
||||
|
||||
const keyMap = { TOGGLE_MENU: 'm' }
|
||||
const keyHandlers = {
|
||||
TOGGLE_MENU: useCallback(() => dispatch(toggleSidebar()), [dispatch]),
|
||||
}
|
||||
|
||||
return (
|
||||
<Layout
|
||||
{...props}
|
||||
className={classes.root}
|
||||
menu={Menu}
|
||||
appBar={AppBar}
|
||||
theme={theme}
|
||||
notification={Notification}
|
||||
/>
|
||||
<HotKeys handlers={keyHandlers} keyMap={keyMap}>
|
||||
<Layout
|
||||
{...props}
|
||||
className={classes.root}
|
||||
menu={Menu}
|
||||
appBar={AppBar}
|
||||
theme={theme}
|
||||
notification={Notification}
|
||||
/>
|
||||
</HotKeys>
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user