Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invariant Violation: scrollToIndex out of range: requested index 28 is out of 0 to 1, js engine: hermes #275

Open
ds-shubhamsharma opened this issue May 24, 2024 · 5 comments

Comments

@ds-shubhamsharma
Copy link

No description provided.

@gabrielroodriz
Copy link

I solved this inside the Dropdows.tsx Index file

const scrollIndex = useCallback(() => {
  if (autoScroll && data.length > 0 && listData?.length === data?.length) {
    setTimeout(() => {
      if (refList && refList?.current) {
        const defaultValue = typeof value === 'object' ? _.get(value, valueField) : value;

        const index = _.findIndex(listData, (e) => _.isEqual(defaultValue, _.get(e, valueField)));

        if (index > -1 && index < listData.length) {
          try {
            refList.current.scrollToIndex({
              index: index,
              animated: false,
            });
          } catch (error) {
            console.warn(`scrollToIndex error: ${error.message}`);
          }
        } else {
          console.warn(`scrollToIndex out of range: requested index ${index} is out of 0 to ${listData.length - 1}`);
        }
      }
    }, 200);
  }
}, [autoScroll, data.length, listData, value, valueField, refList]);

@priyanshubuddy
Copy link

priyanshubuddy commented Jun 11, 2024

getting this error, again and again, need to be fixed, @gabrielroodriz you code converted the mi into warning but it's not worthy to edit in node modules for local use until it's merged in the library.

@gabrielroodriz
Copy link

Yes, I have a pull request open, waiting for approval for it: #279

@kannan-rjp
Copy link

kannan-rjp commented Jun 13, 2024

Hi @gabrielroodriz , I faced this error. And apply your above file to my Dropdown index.tsx. It worked, but which selected it's not get select in my dropdown as a selected city its not appeared.
What should i do?

@daibergm
Copy link

It bug was fixed on the version 2.10.4:

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants