a way to wrap component with React.Suspense as suspense
prop.
<Component suspense={<Fallback />} />
↓ ↓ ↓ ↓ ↓ ↓
<React.Suspense fallback={<Fallback />}><Component /></React.Suspense
- 🤖 Smart enough to import and use
Suspense
based on user source. - 🌟 Simply to adopt (just add new attributes or props in your element with
suspense
as key and value asfallback
.
[Back to the Table of Contents] ↑
[Back to the Getting Started] ↑
- yarn
yarn add babel-plugin-react-suspense
- npm
npm -i babel-plugin-react-suspense
[Back to the Getting Started] ↑
// babel configuration
-- plugins: []
++ plugins: ["babel-plugin-react-suspense"]
[Back to the Getting Started] ↑
This babel plugin will enable special prop name (attributes jsx) called suspense
every JSXElement
declaration. (seem like css
prop, if you familiar with styled-component
or emotion
).
const App = () => (
<>
<User suspense={<Fallback />} />
</>
);
[Back to the Table of Contents] ↑
RiN 💻 🤔 📖 🚇 🔧 |