From 136b6e288ecd0a20c569338f6faa919eae79dcba Mon Sep 17 00:00:00 2001 From: NikolaBorislavovHristov Date: Mon, 22 Apr 2019 12:14:27 +0300 Subject: [PATCH] Route callback memoized with hooks --- src/navigation/Router/Route.js | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/src/navigation/Router/Route.js b/src/navigation/Router/Route.js index e66388334..819b09c85 100644 --- a/src/navigation/Router/Route.js +++ b/src/navigation/Router/Route.js @@ -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 ( +
+ + +
+ {children} +
+
+
+
+ ); }; -const Route = ({ children }) => ( -
- - -
- {children} -
-
-
-
-); - Route.propTypes = { children: PropTypes.oneOfType([ PropTypes.arrayOf(PropTypes.node),