Improved createEffect and cleanup

This commit is contained in:
Patrick Alvin Alcala 2025-06-05 15:49:59 +08:00
parent 24de3a4c6c
commit 307f624015

View file

@ -4,7 +4,6 @@ import Button from '../../Button/Button'
import MiniCard from '../../MiniCard/MiniCard' import MiniCard from '../../MiniCard/MiniCard'
// import ToggleSwtich from '../ToggleSwitch/ToggleSwitch' // import ToggleSwtich from '../ToggleSwitch/ToggleSwitch'
import { Slider } from '@kobalte/core/slider' import { Slider } from '@kobalte/core/slider'
import { Switch } from '@kobalte/core/switch'
import { Alert } from '@kobalte/core/alert' import { Alert } from '@kobalte/core/alert'
import { Checkbox } from '@kobalte/core/checkbox' import { Checkbox } from '@kobalte/core/checkbox'
import { FaSolidCheck } from 'solid-icons/fa' import { FaSolidCheck } from 'solid-icons/fa'
@ -31,9 +30,10 @@ export default () => {
setPassword(passwordArray.join('')) setPassword(passwordArray.join(''))
} }
// Effect to update the display when the length changes createEffect((value) => {
createEffect(() => { if (length() !== value) {
generatePassword() generatePassword()
}
}) })
const handleToggleChange = (target: string) => { const handleToggleChange = (target: string) => {