Use jsx extension
This commit is contained in:
parent
98be7e2076
commit
1c164c4376
28 changed files with 2 additions and 1 deletions
24
app/javascript/components/Loadable.jsx
Normal file
24
app/javascript/components/Loadable.jsx
Normal file
|
@ -0,0 +1,24 @@
|
|||
import React, { Suspense, lazy } from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
|
||||
const Loader = () => <div className="spinner left" />;
|
||||
|
||||
function LazyLoad({ component: Component, ...props }) {
|
||||
return (
|
||||
<Suspense fallback={<Loader />}>
|
||||
<Component {...props} />
|
||||
</Suspense>
|
||||
);
|
||||
}
|
||||
|
||||
LazyLoad.propTypes = {
|
||||
component: PropTypes.object
|
||||
};
|
||||
|
||||
export default function Loadable(loader) {
|
||||
const LazyComponent = lazy(loader);
|
||||
|
||||
return function PureComponent(props) {
|
||||
return <LazyLoad component={LazyComponent} {...props} />;
|
||||
};
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue