fix(v2): introduce useCollapsible to fix collapsible animation perf issues (#5116)

* fix(v2): avoid slowdown transition with huge sidebar items

* move useCollapsible to theme-common

* @docusaurus/theme-classic => watch mode should include type-checking

* refactor useCollapsible => encapsulate more behavior / state / ref inside it, making code simpler for component using it

* useCollapseAnimation => animate DOM properties directly instead of using React inline styles => optimize perf from 4 render per click to 1 render per click

* add missing items in deps array

* rename ref to collapsibleRef

* lint

Co-authored-by: slorber <lorber.sebastien@gmail.com>
This commit is contained in:
Alexey Pyltsyn 2021-07-07 19:50:13 +03:00 committed by GitHub
parent ef70de18dd
commit 237d1a31f5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 201 additions and 54 deletions

View file

@ -37,6 +37,12 @@ export {useLocationChange} from './utils/useLocationChange';
export {usePrevious} from './utils/usePrevious';
export {useCollapsible} from './utils/useCollapsible';
export type {
UseCollapsibleConfig,
UseCollapsibleReturns,
} from './utils/useCollapsible';
export {
useDocsPreferredVersion,
useDocsPreferredVersionByPluginId,