fix: memory leak fix (#1610)

* fix: memory leak

* Style change
This commit is contained in:
Jason Law
2019-11-29 21:14:04 -07:00
committed by Tanner Linsley
parent 301ab1b991
commit 0a512adaf0
5 changed files with 50 additions and 11 deletions
+12 -5
View File
@@ -168,6 +168,10 @@ function useMain(instance) {
}, actions.toggleRowSelected)
}
// use reference to avoid memory leak in #1608
const instanceRef = React.useRef()
instanceRef.current = instance
const getToggleAllRowsSelectedProps = props => {
return mergeProps(
{
@@ -180,7 +184,10 @@ function useMain(instance) {
checked: isAllRowsSelected,
title: 'Toggle All Rows Selected',
},
applyPropHooks(instance.hooks.getToggleAllRowsSelectedProps, instance),
applyPropHooks(
instanceRef.current.hooks.getToggleAllRowsSelectedProps,
instanceRef.current
),
props
)
}
@@ -216,9 +223,9 @@ function useMain(instance) {
title: 'Toggle Row Selected',
},
applyPropHooks(
instance.hooks.getToggleRowSelectedProps,
instanceRef.current.hooks.getToggleRowSelectedProps,
row,
instance
instanceRef.current
),
props
)
@@ -246,9 +253,9 @@ function useMain(instance) {
title: 'Toggle Row Selected',
},
applyPropHooks(
instance.hooks.getToggleRowSelectedProps,
instanceRef.current.hooks.getToggleRowSelectedProps,
row,
instance
instanceRef.current
),
props
)