diff --git a/text/0000-lazy.md b/text/0000-lazy.md new file mode 100644 index 00000000..9cf41d19 --- /dev/null +++ b/text/0000-lazy.md @@ -0,0 +1,113 @@ + +Start Date: 2018-10-19 +- RFC PR: (leave this empty) +- React Issue: (leave this empty) + +# Summary + +`React.lazy` adds first-class support for code splitting components to React. It takes a module object and returns a special component type. + +>Note +> +>This RFC is intentionally scoped to supporting default imports. We may in the future submit another RFC concerning named imports. In the meantime you can also implement support for named imports in userland with a lower-level Suspense API (to be discussed in another RFC). + +# Basic example + +```js +import Input from './Input'; // Regular import +const Button = React.lazy(() => import('./Button')); // Dynamic import + +function Dialog() { + // You can mix normal and lazy-loaded components in one tree + return ( +
+ +