Skip to content

Commit

Permalink
Fix crashing on utils change
Browse files Browse the repository at this point in the history
  • Loading branch information
dmtrKovalenko committed Jun 8, 2019
1 parent 04773f1 commit 14fa8d5
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion docs/_shared/Example.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import GithubIcon from '_shared/svgIcons/GithubIcon';
import React, { useState, useCallback, useMemo, useContext } from 'react';
import { copy } from 'utils/helpers';
import { GITHUB_EDIT_URL } from '_constants';
import { useUtils } from '@material-ui/pickers';
import { replaceGetFormatStrings } from 'utils/utilsService';
import { withSnackbar, InjectedNotistackProps } from 'notistack';
import { withUtilsService, UtilsContext } from './UtilsServiceContext';
Expand Down Expand Up @@ -66,6 +67,7 @@ function Example({ source, enqueueSnackbar }: Props) {
);
}

const utils = useUtils();
const classes = useStyles();
const currentLib = useContext(UtilsContext).lib;
const [expanded, setExpanded] = useState(false);
Expand Down Expand Up @@ -121,7 +123,10 @@ function Example({ source, enqueueSnackbar }: Props) {
</IconButton>
</Tooltip>

<Component />
<Component
// remount component when utils changed
key={utils.constructor.name}
/>
</div>
</>
);
Expand Down

0 comments on commit 14fa8d5

Please sign in to comment.