小编Mah*_*yar的帖子

requireNativeComponent:在 React Native 中使用 flash 列表时的“AutoLayoutView”

我想用来flashlist将项目渲染到屏幕上,根据文档,我们唯一需要做的就是重命名组件并向estimatedItemSize组件添加属性,所以我这样做了,但出现了这个奇怪的错误。

组件代码:


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>
  );
};

Run Code Online (Sandbox Code Playgroud)

错误是:

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 …
Run Code Online (Sandbox Code Playgroud)

javascript react-native

9
推荐指数
2
解决办法
5047
查看次数

标签 统计

javascript ×1

react-native ×1