Skip to content

Commit

Permalink
fix: revert back to toggle group controlled state
Browse files Browse the repository at this point in the history
  • Loading branch information
lovrozagar committed Jul 5, 2024
1 parent c745e33 commit b8e3c24
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 16 deletions.
7 changes: 1 addition & 6 deletions app.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@

import React, { useState } from 'react'

const App = () => {
const [state, setValue] = useState(false)

return (

<div className='h-screen w-full flex flex-col justify-center items-center gap-8'> </div>

)
return <div className='h-screen w-full flex flex-col justify-center items-center gap-8'> </div>
}

export { App }
1 change: 0 additions & 1 deletion src/components/number-input/hooks/use-number-input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { useControllableState } from '@/components/_shared/hooks/use-controllabl
import { useMergedRef } from '@/components/_shared/hooks/use-merged-ref'
import { useOnClickOutside } from '@/components/_shared/hooks/use-on-click-outside'
import { focusInput } from '@/components/_shared/utils/focus-input'
import { buttonClasses } from '@/components/button'
import {
DEFAULT_NUMBER_INPUT_CLASSNAME,
DEFAULT_NUMBER_INPUT_CONTAINER_CLASSNAME,
Expand Down
4 changes: 0 additions & 4 deletions src/components/text-input/hooks/use-text-input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@ import { inputContainerClasses } from '@/components/_shared/classes/input-contai
import { useControllableState } from '@/components/_shared/hooks/use-controllable-state'
import { useMergedRef } from '@/components/_shared/hooks/use-merged-ref'
import { useOnClickOutside } from '@/components/_shared/hooks/use-on-click-outside'
<<<<<<< HEAD
import { buttonClasses } from '@/components/button'
=======
>>>>>>> d68c9fe (refactor: internal hook rewrite, update deps)
import {
DEFAULT_TEXT_INPUT_BASE_PASSWORD_TOGGLE_ICON_CLASSNAME,
DEFAULT_TEXT_INPUT_CLASSNAME,
Expand Down
11 changes: 6 additions & 5 deletions src/components/toggle-group/components/toggle-group.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,10 @@

import { ToggleGroup as ToggleGroupPrimitive } from '@radix-ui/react-toggle-group'
import { cn, functionCallOrValue } from '@renderui/utils'
import React, { useState } from 'react'
import React from 'react'

import { EMPTY_ARRAY } from '@/components/_shared/constants/constants'
<<<<<<< HEAD
import { useControllableState } from '@/components/_shared/hooks/use-controllable-state'
=======
>>>>>>> d68c9fe (refactor: internal hook rewrite, update deps)
import { DEFAULT_TOGGLE_GROUP_CLASSNAME } from '@/components/toggle-group/constants/constants'
import { ToggleGroupProvider } from '@/components/toggle-group/contexts/toggle-group-context'
import { ToggleGroupProps, ToggleGroupRef } from '@/components/toggle-group/types/toggle-group'
Expand All @@ -24,7 +21,11 @@ const ToggleGroup = React.forwardRef<ToggleGroupRef, ToggleGroupProps>((props, r
...restProps
} = props

const [value, onValueChange] = useState(valueProp ?? defaultValue)
const [value, onValueChange] = useControllableState<any>({
onChange: onValueChangeProp,
defaultProp: defaultValue,
prop: valueProp,
})

return (
<ToggleGroupPrimitive
Expand Down

0 comments on commit b8e3c24

Please sign in to comment.