Skip to content

a new selectedIndex makes the view to disappear #64

@Francesco-Voto

Description

@Francesco-Voto

Hello,

I started to use this library, everything works fine until I need to set a selectedIndex .

Here the code:

  const [selectedIndex, setSelectedIndex] = useState(10)
  const {t} = useTranslation('account')

  const options = useRef(
    Array.from(
      {length: MAX_WEEK - MIN_WEEK + 1},
      (_, index) => `${t('changeYourPregnancyWeek.week')} ${index + MIN_WEEK}`
    )
  )


  const onChangeOption = useCallback((index: number) => {
    setSelectedIndex(index)
  }, [])

  return (
    <WheelPicker
      selectedIndex={selectedIndex}
      options={options.current}
      onChange={onChangeOption}
    />
  )
}

What happens is:

Registrazione.schermo.2023-10-26.alle.09.44.25.mov

It happens for me on both platform.

I try to investigate a bit and apparently setting the animated option to true inside the scrollToIndex methods fixes the problem

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions