Skip to content

Commit

Permalink
fixed rendering both light and heavy which consumes bandwidth
Browse files Browse the repository at this point in the history
  • Loading branch information
anton-karlovskiy committed Aug 17, 2019
1 parent f3c898e commit bd5afdc
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions cra-ua-aware-code-splitting/src/components/Product/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ const Loading = <Fragment>Loading...</Fragment>;

const Product = ({ ...rest }) => {
const deviceClass = useDeviceClass();

// without this at first Light rendered regardless of deviceClass because the initial deviceClass is null
if (!deviceClass) return Loading;

return (
<LazyLoadingErrorBoundary>
<Suspense fallback={Loading}>
Expand Down

0 comments on commit bd5afdc

Please sign in to comment.