negomi / react-burger-menu

:hamburger: An off-canvas sidebar component with a collection of effects and styles using CSS transitions and SVG path animations
http://negomi.github.io/react-burger-menu/
MIT License
5.05k stars 586 forks source link

How to do lazy loading #356

Closed oneandonlyonebutyou closed 4 years ago

oneandonlyonebutyou commented 4 years ago

Base on examples I import :

import { push as Menu } from 'react-burger-menu';

I wonder how can I do lazy importing to split my code .. Thanks..

negomi commented 4 years ago

Hey, not sure what you mean - do you mean Webpack tree shaking?

oneandonlyonebutyou commented 4 years ago

The component I use "react-burger-menu" is getting very big. and based on my understanding, if I lazy load the component, Webpack will break them up to smaller pieces and load them when it is needed. I wonder if it would apply to the case as well.

pasleto commented 4 years ago

The component I use "react-burger-menu" is getting very big. and based on my understanding, if I lazy load the component, Webpack will break them up to smaller pieces and load them when it is needed. I wonder if it would apply to the case as well.

This might help you:

import Menu from 'react-burger-menu/lib/menus/push';

Mukhammadali commented 4 years ago

The component I use "react-burger-menu" is getting very big. and based on my understanding, if I lazy load the component, Webpack will break them up to smaller pieces and load them when it is needed. I wonder if it would apply to the case as well.

You can use React.lazy or react-loadable for that, I guess

stale[bot] commented 4 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.