mirror of
https://github.com/Stremio/stremio-web.git
synced 2026-08-18 09:27:02 +00:00
Route callback memoized with hooks
This commit is contained in:
parent
49fa139d6d
commit
136b6e288e
1 changed files with 15 additions and 14 deletions
|
|
@ -4,22 +4,23 @@ const { FocusableProvider } = require('../FocusableContext');
|
|||
const { ModalsContainerProvider } = require('../ModalsContainerContext');
|
||||
const styles = require('./styles');
|
||||
|
||||
const onModalsContainerDomTreeChange = ({ modalsContainerElement }) => {
|
||||
return modalsContainerElement.childElementCount === 0;
|
||||
const Route = ({ children }) => {
|
||||
const onModalsContainerDomTreeChange = React.useCallback(({ modalsContainerElement }) => {
|
||||
return modalsContainerElement.childElementCount === 0;
|
||||
}, []);
|
||||
return (
|
||||
<div className={styles['route']}>
|
||||
<ModalsContainerProvider modalsContainerClassName={styles['modals-container']}>
|
||||
<FocusableProvider onModalsContainerDomTreeChange={onModalsContainerDomTreeChange}>
|
||||
<div className={styles['route-content']}>
|
||||
{children}
|
||||
</div>
|
||||
</FocusableProvider>
|
||||
</ModalsContainerProvider>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
const Route = ({ children }) => (
|
||||
<div className={styles['route']}>
|
||||
<ModalsContainerProvider modalsContainerClassName={styles['modals-container']}>
|
||||
<FocusableProvider onModalsContainerDomTreeChange={onModalsContainerDomTreeChange}>
|
||||
<div className={styles['route-content']}>
|
||||
{children}
|
||||
</div>
|
||||
</FocusableProvider>
|
||||
</ModalsContainerProvider>
|
||||
</div>
|
||||
);
|
||||
|
||||
Route.propTypes = {
|
||||
children: PropTypes.oneOfType([
|
||||
PropTypes.arrayOf(PropTypes.node),
|
||||
|
|
|
|||
Loading…
Reference in a new issue