davidhu2000 / react-spinners

A collection of loading spinner components for react
https://www.davidhu.io/react-spinners
MIT License
3.01k stars 262 forks source link

react-spinners does not compile when being hoisted #460

Closed sguillia closed 2 years ago

sguillia commented 2 years ago

Describe the bug Demo code doesn't build when react-spinners lives in a node_modules higher up in the tree

Example tree

node_modules
└── react-spinners

my-app
├── src
│   ├── App.tsx
├── node_modules
└── └── react-scripts

This tree is a standard tree when using yarn workspaces This tree respects the node module resolution algorithm

To Reproduce Steps to reproduce the behavior:

  1. cd /tmp
  2. npx create-react-app my-app --template typescript
  3. cd my-app
  4. Copy demo code from https://www.npmjs.com/package/react-spinners into my-app/src/App.tsx
  5. npm install react-spinners
  6. mkdir ../node_modules
  7. mv node_modules/react-spinners ../node_modules
  8. npm run build

Expected behavior

Compiles

Actual behavior

Creating an optimized production build...
Failed to compile.

TS2607: JSX element class does not support attributes because it does not have a 'props' property.
    19 |       <input value={color} onChange={(input) => setColor(input.target.value)} placeholder="Color of the loader" />
    20 |
  > 21 |       <ClipLoader color={color} loading={loading} css={override} size={150} />
       |       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    22 |     </div>
    23 |   );
    24 | }
davidhu2000 commented 2 years ago

@sguillia i tried to reproduce using the latest version. maybe 0.12.0 resolved this issue. can you check?

sguillia commented 2 years ago

@davidhu2000 I'm having the same issue with 0.12.0

davidhu2000 commented 2 years ago

@sguillia i'm not sure how, but this seems fixed on 0.13.0-beta.4. mind giving that a try?

I did reproduce this issue on 0.12.0, and then tried again on 0.13 and it worked.

i see this on 0.13

Screen Shot 2022-06-04 at 6 20 09 PM

vs 0.12

Screen Shot 2022-06-04 at 6 20 50 PM
sguillia commented 2 years ago

@davidhu2000 It works with 0.13.0-beta.4. Thank you!