1
0
mirror of https://github.com/phuoc-ng/csslayout.git synced 2025-08-06 06:07:33 +02:00

Fix an issue that couldn't link to other pattern

This commit is contained in:
Phuoc Nguyen
2019-11-24 22:04:13 +07:00
parent de311f6fe5
commit 849cf45482
4 changed files with 21 additions and 1 deletions

View File

@@ -1,4 +1,5 @@
{
"plugins": ["@loadable/babel-plugin"],
"presets": [
"@babel/preset-env",
"@babel/preset-react"

View File

@@ -5,7 +5,16 @@ import './spinner.css';
const slug = item => item.toLowerCase().split(' ').join('-');
const DetailsLoader = loadable(props => import(`../patterns/${slug(props.pattern)}/Details`), {
// In order to create a link to another page that is dynamically loaded (via <Link to="...">),
// the page chunks have to be loadable by @loadable.
// We have to add a magic comment /* #__LOADABLE__ */ here
// and the following plugin to Babel's settings (.babelrc):
// {
// "plugins": ["@loadable/babel-plugin"],
// }
const loadDetails = /* #__LOADABLE__ */ (props) => import(`../patterns/${slug(props.pattern)}/Details`)
const DetailsLoader = loadable(loadDetails, {
fallback: (
<div className="w100 h-100 flex items-center justify-center">
<svg className="spinner" width="64px" height="64px" viewBox="0 0 32 32">

9
package-lock.json generated
View File

@@ -1942,6 +1942,15 @@
"regenerator-runtime": "^0.13.2"
}
},
"@loadable/babel-plugin": {
"version": "5.10.3",
"resolved": "https://registry.npmjs.org/@loadable/babel-plugin/-/babel-plugin-5.10.3.tgz",
"integrity": "sha512-Izo4QX526f/Czvdot1izg0DtA5DfJEW5RUN28/9wt+62It4xKhVv9l0NNcTEL39xJXj7lsE4k5Z6eCBSETpHmw==",
"dev": true,
"requires": {
"@babel/plugin-syntax-dynamic-import": "^7.2.0"
}
},
"@loadable/component": {
"version": "5.10.3",
"resolved": "https://registry.npmjs.org/@loadable/component/-/component-5.10.3.tgz",

View File

@@ -21,6 +21,7 @@
"@babel/core": "^7.7.4",
"@babel/preset-env": "^7.7.4",
"@babel/preset-react": "^7.7.4",
"@loadable/babel-plugin": "^5.10.3",
"babel-loader": "^8.0.6",
"css-loader": "^3.2.0",
"html-webpack-plugin": "^3.2.0",