You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Code Splitting can be done easily using [`React.lazy`](https://reactjs.org/docs/code-splitting.html#reactlazy). It is true if you don't need Server Side Rendering or complex features like [full dynamic imports](https://webpack.js.org/api/module-methods/#import-).
21
+
Code splitting is supported out of the box by React using [`React.lazy`](https://reactjs.org/docs/code-splitting.html#reactlazy). So what is the goal of this library?
22
22
23
-
Loadable leverage the limit of Code Splitting and give you access to all features.
23
+
`@loadable/component` pushes the limit of Code splitting, it offers several features:
24
24
25
-
Code Splitting + Server Side Rendering is something very complex. Several libraries tried to solve this problem successfully or not. The goal of this library is to follow as much as possible the philosophy of React and give a developer-experience first solution to solve this complex problem. It takes the best from all libraries and provide an elegant solution to this problem.
25
+
- 📚 Library splitting
26
+
- ⚡️ Prefetching
27
+
- 💫 Server Side Rendering
28
+
- 🎛 Full dynamic import `` import(`./${value}`) ``
26
29
27
-
## Differences with React.lazy & react-loadable
30
+
## Comparison with React.lazy & react-loadable
28
31
29
-
[`React.lazy`](https://reactjs.org/docs/code-splitting.html#reactlazy) doesn't support full dynamic import and SSR. Loadable uses the same API with more features (SSR, full dynamic import, library import). If you don't need them, you don't need `loadable`.
Even if [`react-loadable` is recommended by React team](https://reactjs.org/docs/code-splitting.html#reactlazy), the project does not accept any GitHub issues and is no longer maintained.
38
+
Even if [`react-loadable` is recommended by React team](https://reactjs.org/docs/code-splitting.html#reactlazy), the project does not accept any GitHub issue and is no longer maintained.
38
39
39
40
## Getting started
40
41
@@ -74,7 +75,7 @@ function FromNow({ date }) {
74
75
}
75
76
```
76
77
77
-
You can also use a `ref` that will be populated when the library will be loaded.
78
+
You can also use a `ref`, populated when the library is loaded.
78
79
79
80
```js
80
81
importloadablefrom'@loadable/component'
@@ -101,11 +102,11 @@ class MyComponent {
101
102
}
102
103
```
103
104
104
-
> You can also pass a function to `ref`, called when the library will be loaded.
105
+
> You can also pass a function to `ref`, called when the library is loaded.
105
106
106
107
### Full dynamic import
107
108
108
-
Webpack accepts [full dynamic imports](https://webpack.js.org/api/module-methods/#import-) and you can also use them with `@loadable/component`to create dynamic components.
109
+
Webpack accepts [full dynamic imports](https://webpack.js.org/api/module-methods/#import-), you can use them to create a reusable Loadable Component.
109
110
110
111
```js
111
112
importloadablefrom'@loadable/component'
@@ -144,7 +145,7 @@ function MyComponent() {
144
145
145
146
> Use `lazy.lib` for libraries.
146
147
147
-
> Suspense is not yet available for server-side rendering.
148
+
> ⚠️ Suspense is not yet available for server-side rendering.
> With suspense, use `<Suspense maxDuration={200}>` to have the same effect.
218
+
216
219
### Timeout
217
220
218
221
Infinite loading is not good for user experience, to avoid it implementing a timeout is a good workaround. You can do it using a third party module like [`promise-timeout`](https://github.com/building5/promise-timeout):
@@ -268,7 +271,7 @@ function MyComponent() {
268
271
269
272
> `prefetch` and `Prefetch` are also available for components created with `lazy`, `loadable.lib` and `lazy.lib`.
270
273
271
-
> Only component based prefetching is compatible with Server Side Rendering.
274
+
> Only component based prefetching (`<Prefetch>`) is compatible with Server Side Rendering.
0 commit comments