diff --git a/packages/components/src/Packages/Editors/org.standardnotes.advanced-checklist/src/app/hooks.ts b/packages/components/src/Packages/Editors/org.standardnotes.advanced-checklist/src/app/hooks.ts index bad2dfc77..453dae958 100644 --- a/packages/components/src/Packages/Editors/org.standardnotes.advanced-checklist/src/app/hooks.ts +++ b/packages/components/src/Packages/Editors/org.standardnotes.advanced-checklist/src/app/hooks.ts @@ -1,5 +1,5 @@ -import React, { useEffect, useRef, useState } from 'react' import useResizeObserver from '@react-hook/resize-observer' +import React, { useEffect, useRef, useState } from 'react' import { TypedUseSelectorHook, useDispatch, useSelector } from 'react-redux' import type { AppDispatch, RootState } from './store' @@ -42,3 +42,13 @@ export const useDebouncedCallback = (callback: () => void, waitMs: number = 500) callback() }, waitMs) } + +export const usePrevious = (value: any) => { + const ref = useRef() + + useEffect(() => { + ref.current = value + }, [value]) + + return ref.current +} diff --git a/packages/components/src/Packages/Editors/org.standardnotes.advanced-checklist/src/common/components/CheckBoxInput.tsx b/packages/components/src/Packages/Editors/org.standardnotes.advanced-checklist/src/common/components/CheckBoxInput.tsx index 9a9727646..62e0f2a65 100644 --- a/packages/components/src/Packages/Editors/org.standardnotes.advanced-checklist/src/common/components/CheckBoxInput.tsx +++ b/packages/components/src/Packages/Editors/org.standardnotes.advanced-checklist/src/common/components/CheckBoxInput.tsx @@ -1,18 +1,15 @@ -import React, { ChangeEvent, forwardRef } from 'react' +import { ChangeEvent, forwardRef, MouseEvent } from 'react' type CheckBoxInputProps = { checked?: boolean disabled?: boolean testId?: string onChange?: (event: ChangeEvent) => void + onClick?: (event: MouseEvent) => void } export const CheckBoxInput = forwardRef( - ({ checked, disabled, testId, onChange }, ref) => { - function onCheckBoxButtonClick({ currentTarget }: React.MouseEvent) { - !checked ? currentTarget.classList.add('explode') : currentTarget.classList.remove('explode') - } - + ({ checked, disabled, testId, onChange, onClick }, ref) => { return (