最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - requireNativeComponent: "AutoLayoutView" when using flash list in React Native - Stack Overflow

programmeradmin3浏览0评论

i want to use flashlistto render items to the screen , acording to the docs the only thing that we need to do is to rename the component and add estimatedItemSize attribute to the component , so i did it but i got this weird error .

component code :


export const RestaurantsScreen = () => {
  const { isLoading, error, clearError, sendRequest } = useHttpClient();
  const [fetchedRestaurants, setFetchedRestaurants] = useState([]);

...
...
...

      {!isLoading && fetchedRestaurants.length > 0 && (
        <FlashList
          data={fetchedRestaurants}
          renderItem={renderItemComponent}
          keyExtractor={(item) => item.name}
          initialNumToRender={3}
          estimatedItemSize={15}
        />
      )}
    </SafeArea>
  );
};

and the error is :

Invariant Violation: requireNativeComponent: "AutoLayoutView" was not found in the UIManager.

This error is located at:
    in AutoLayoutView (created by AutoLayoutView)
    in AutoLayoutView (created by ScrollComponent)
    in RCTView (created by View)
    in View (created by ScrollComponent)
    in ...

it works fine with flatlist .

i want to use flashlistto render items to the screen , acording to the docs the only thing that we need to do is to rename the component and add estimatedItemSize attribute to the component , so i did it but i got this weird error .

component code :


export const RestaurantsScreen = () => {
  const { isLoading, error, clearError, sendRequest } = useHttpClient();
  const [fetchedRestaurants, setFetchedRestaurants] = useState([]);

...
...
...

      {!isLoading && fetchedRestaurants.length > 0 && (
        <FlashList
          data={fetchedRestaurants}
          renderItem={renderItemComponent}
          keyExtractor={(item) => item.name}
          initialNumToRender={3}
          estimatedItemSize={15}
        />
      )}
    </SafeArea>
  );
};

and the error is :

Invariant Violation: requireNativeComponent: "AutoLayoutView" was not found in the UIManager.

This error is located at:
    in AutoLayoutView (created by AutoLayoutView)
    in AutoLayoutView (created by ScrollComponent)
    in RCTView (created by View)
    in View (created by ScrollComponent)
    in ...

it works fine with flatlist .

Share Improve this question edited Dec 11, 2022 at 6:26 Mahdyar asked Aug 18, 2022 at 9:13 MahdyarMahdyar 1991 silver badge14 bronze badges
Add a comment  | 

6 Answers 6

Reset to default 12

The reason for this is that flashlist module has native dependencies (this is why installation docs prompts you to install the native deps with pod install in the ios directory).

Whenever you change anything on the "native" side of things you need to rebuild the app via xCode (or with yarn ios).

After that you will not see the error anymore

发布评论

评论列表(0)

  1. 暂无评论