ReactNative

A collection of 4 posts
ReactNative

React ReactNative通用异步引入组件解决方案

实际开发中,难免会遇到一个页面会依赖很多组件的,但都是通过接口下发的条件进行动态引入的。 React已经为我们提供了一种异步引入组件的通用方法,上代码: import React, { Suspense } from "react"; const LazyLargeComponent = React.lazy(() => { return new Promise(resolve => setTimeout(resolve, 5 * 1000)).then( () => import("../components/LargeComponent") ); }); export default function LargeComponent() { return ( <div> <Suspense fallback={<div>loading...</div}
1 min read