react-use icon indicating copy to clipboard operation
react-use copied to clipboard

react-use doesn't support webpack 5 tree shaking

Open guoyunhe opened this issue 3 years ago • 2 comments

What is the current behavior?

I installed react-use and only imported one hook:

import { useLocalStorage } from 'react-use'; 

But the build result bundled all hooks:

image

What is the expected behavior?

react-use should support webpack 5 tree shaking and only bundle useLocalStorage.js and depended modules.

A little about versions:

  • OS:
  • Browser (vendor and version):
  • React:
  • react-use:
  • Did this worked in the previous package version?

guoyunhe avatar Jun 27 '22 02:06 guoyunhe

Are you shure?

image

ailchenkoDynamo avatar Jul 06 '22 11:07 ailchenkoDynamo

@guoyunhe By looking at the folder structure for the installed package it looks like we can import the individual functions directly like this:

import useLocalStorage from 'react-use/lib/useLocalStorage';
image

Although I am not sure if this is the right way to this

harryi3t avatar Jul 08 '22 08:07 harryi3t