Skip to content

Commit

Permalink
fix: react refresh and maximinStackExceeded
Browse files Browse the repository at this point in the history
  • Loading branch information
tommmyy committed Jan 27, 2024
1 parent f2b3115 commit 98159e9
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -85,14 +85,14 @@ const getNav = ({
);
/* eslint-enable react/prop-types */

const hashToId = str => str.slice(1);
const getHeadingIds = (
items,
traverseFullDepth = true,
depth,
recursionDepth = 1,
) => {
const idList = [];
const hashToId = str => str.slice(1);

if (items) {
for (const item of items) {
Expand Down
8 changes: 4 additions & 4 deletions packages/gatsby-theme-fast-ai-sidebar/src/templates/Page.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable react/prop-types */
import React, { Fragment, useEffect, useRef, useState } from 'react';
import PropTypes from 'prop-types';
import { Box, Container, useBreakpoint } from '@fast-ai/ui-components';
Expand Down Expand Up @@ -31,14 +32,15 @@ const Root = ({ sx, ...rest }) => (
/>
);

/* eslint-disable react/prop-types */
const PageInner = ({
children,
fluidLayout,
disableBreadcrumbs,
fullWidth: deprecatedFullwidth,
showContentNavigation: showContentNavigationProp,
}) => {
const isMdUp = useBreakpoint('md', 'up');
// const isMdUp = true;
const [menuVisibility, setMenuVisibility] = useState(false);
const [appSidebarVisibility, setAppSidebarVisibility] = useState(false);
const nav = useRef(null);
Expand All @@ -57,7 +59,7 @@ const PageInner = ({
presentedRoutes = lastRoot.children || [];
}
}
const shouldUseMobileNavigation = !useBreakpoint('md', 'up') && !isSSR;
const shouldUseMobileNavigation = !isMdUp && !isSSR;

useEffect(() => {
setMenuVisibility(false);
Expand Down Expand Up @@ -133,8 +135,6 @@ const PageInner = ({
</Root>
);
};
/* eslint-enable react/prop-types */

const Page = props => (
<IntlProxyContextProvider>
<PageInner {...props} />
Expand Down
12 changes: 6 additions & 6 deletions packages/ui-components/src/hooks/useBreakpoint.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,15 @@ const useBreakpoint = (...args) => {
// Styled-system use alias `_` for the smallest breakpoint.
const mapping = zipObj(['_', ...aliases], [0, ...breakpoints]);

const mappingHash = JSON.stringify(mapping);
const mappingHash = JSON.stringify([mapping, ...args]);

// eslint-disable-next-line
const useBreakpoint = useMemo(
() => createBreakpointHook(mapping),
[mappingHash],
);
const useBreakpointMemo = useMemo(() => {
return createBreakpointHook(mapping);
}, [mappingHash]);
createBreakpointHook(mapping);

return useBreakpoint(...args);
return useBreakpointMemo(...args);
};

export default useBreakpoint;
32 changes: 16 additions & 16 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2023,9 +2023,9 @@ __metadata:
dependencies:
"@emotion/core": ^10.0.35
"@emotion/styled": ^10.0.0
"@fast-ai/ui-components": ^1.8.0-alpha.2
"@fast-ai/ui-components": ^1.8.0
gatsby: ^4.12.1
gatsby-theme-fast-ai-sidebar: ^1.8.0-alpha.2
gatsby-theme-fast-ai-sidebar: ^1.8.0
prop-types: ^15.8.1
ramda: ^0.27.0
ramda-extension: ^0.11.0
Expand All @@ -2040,9 +2040,9 @@ __metadata:
dependencies:
"@emotion/core": ^10.0.35
"@emotion/styled": ^10.0.0
"@fast-ai/ui-components": ^1.8.0-alpha.2
"@fast-ai/ui-components": ^1.8.0
gatsby: ^4.12.1
gatsby-theme-fast-ai: ^1.8.0-alpha.2
gatsby-theme-fast-ai: ^1.8.0
prop-types: ^15.8.1
ramda: ^0.27.0
ramda-extension: ^0.11.0
Expand All @@ -2051,7 +2051,7 @@ __metadata:
languageName: unknown
linkType: soft

"@fast-ai/gatsby-plugin-setup@^1.8.0-alpha.2, @fast-ai/gatsby-plugin-setup@workspace:packages/gatsby-plugin-setup":
"@fast-ai/gatsby-plugin-setup@^1.8.0, @fast-ai/gatsby-plugin-setup@workspace:packages/gatsby-plugin-setup":
version: 0.0.0-use.local
resolution: "@fast-ai/gatsby-plugin-setup@workspace:packages/gatsby-plugin-setup"
dependencies:
Expand All @@ -2068,7 +2068,7 @@ __metadata:
languageName: unknown
linkType: soft

"@fast-ai/gatsby-plugin-staged-fonts@^1.8.0-alpha.2, @fast-ai/gatsby-plugin-staged-fonts@workspace:packages/gatsby-plugin-staged-fonts":
"@fast-ai/gatsby-plugin-staged-fonts@^1.8.0, @fast-ai/gatsby-plugin-staged-fonts@workspace:packages/gatsby-plugin-staged-fonts":
version: 0.0.0-use.local
resolution: "@fast-ai/gatsby-plugin-staged-fonts@workspace:packages/gatsby-plugin-staged-fonts"
dependencies:
Expand All @@ -2089,7 +2089,7 @@ __metadata:
resolution: "@fast-ai/storybook@workspace:apps/storybook"
dependencies:
"@babel/core": ^7.17.9
"@fast-ai/ui-components": ^1.8.0-alpha.2
"@fast-ai/ui-components": ^1.8.0
"@storybook/addon-actions": ^5.3.18
"@storybook/addon-docs": ^5.3.18
"@storybook/addon-info": ^5.3.18
Expand All @@ -2111,7 +2111,7 @@ __metadata:
languageName: unknown
linkType: soft

"@fast-ai/ui-components@^1.8.0-alpha.2, @fast-ai/ui-components@workspace:packages/ui-components":
"@fast-ai/ui-components@^1.8.0, @fast-ai/ui-components@workspace:packages/ui-components":
version: 0.0.0-use.local
resolution: "@fast-ai/ui-components@workspace:packages/ui-components"
dependencies:
Expand Down Expand Up @@ -15430,14 +15430,14 @@ __metadata:
languageName: node
linkType: hard

"gatsby-theme-fast-ai-sidebar@^1.8.0-alpha.2, gatsby-theme-fast-ai-sidebar@workspace:packages/gatsby-theme-fast-ai-sidebar":
"gatsby-theme-fast-ai-sidebar@^1.8.0, gatsby-theme-fast-ai-sidebar@workspace:packages/gatsby-theme-fast-ai-sidebar":
version: 0.0.0-use.local
resolution: "gatsby-theme-fast-ai-sidebar@workspace:packages/gatsby-theme-fast-ai-sidebar"
dependencies:
"@emotion/core": ^10.0.35
"@fast-ai/gatsby-plugin-setup": ^1.8.0-alpha.2
"@fast-ai/gatsby-plugin-staged-fonts": ^1.8.0-alpha.2
"@fast-ai/ui-components": ^1.8.0-alpha.2
"@fast-ai/gatsby-plugin-setup": ^1.8.0
"@fast-ai/gatsby-plugin-staged-fonts": ^1.8.0
"@fast-ai/ui-components": ^1.8.0
"@mdx-js/mdx": ^1.6.16
"@mdx-js/react": ^1.6.16
gatsby-plugin-image: ^2.12.1
Expand Down Expand Up @@ -15465,14 +15465,14 @@ __metadata:
languageName: unknown
linkType: soft

"gatsby-theme-fast-ai@^1.8.0-alpha.2, gatsby-theme-fast-ai@workspace:packages/gatsby-theme-fast-ai":
"gatsby-theme-fast-ai@^1.8.0, gatsby-theme-fast-ai@workspace:packages/gatsby-theme-fast-ai":
version: 0.0.0-use.local
resolution: "gatsby-theme-fast-ai@workspace:packages/gatsby-theme-fast-ai"
dependencies:
"@emotion/core": ^10.0.35
"@fast-ai/gatsby-plugin-setup": ^1.8.0-alpha.2
"@fast-ai/gatsby-plugin-staged-fonts": ^1.8.0-alpha.2
"@fast-ai/ui-components": ^1.8.0-alpha.2
"@fast-ai/gatsby-plugin-setup": ^1.8.0
"@fast-ai/gatsby-plugin-staged-fonts": ^1.8.0
"@fast-ai/ui-components": ^1.8.0
"@mdx-js/mdx": ^1.6.16
"@mdx-js/react": ^1.6.16
gatsby-plugin-image: ^2.12.1
Expand Down

0 comments on commit 98159e9

Please sign in to comment.