> For the complete documentation index, see [llms.txt](https://shenjunhong.gitbook.io/blog/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://shenjunhong.gitbook.io/blog/yuan-ma/react/react-yuan-ma-fen-xi-zhi-lazy.md).

# 使用方式

1. string
2. function
3. createRef

```js
export function createRef(): RefObject {
  const refObject = {
    current: null,
  };
  if (__DEV__) {
    Object.seal(refObject);
  }
  return refObject;
}
```

purecomponent 没有实例

纯函数组件 connect 需要是一个 forwardRef，像这样：const connect = forwardRef(() => {...}) 怎么获取到 ref

```ts
const LazyComp = lazy(() => import("./lazy.js"));

export default () => (
  <Suspense fallback="loading data">
    <SuspenseComp />
    <LazyComp />
  </Suspense>
);

import React from "react";

export default () => <p>Lazy Comp</p>;
```

```js
import type { LazyComponent, Thenable } from "shared/ReactLazyComponent";

import { REACT_LAZY_TYPE } from "shared/ReactSymbols";

export function lazy<T, R>(ctor: () => Thenable<T, R>): LazyComponent<T> {
  return {
    $$typeof: REACT_LAZY_TYPE,
    _ctor: ctor,
    // React uses these fields to store the result.
    _status: -1,
    _result: null,
  };
}
```
