Describe the bug
First off, I'd like to say thanks for putting together such a great library. I hit the ground running with this. Was super excited to see you added the TypeScript documentation as well.
This is similar to https://github.com/udilia/create-react-library/issues/55 in the sense I get the same error but I'm getting it without using rollup - just using the out-of-the-box configuration with the project (except I've added TypeScript).
System
Node.js version: 11.15.0
NPM or Yarn version: Yarn 1.19.1
Operating system: Mac OSX Mojave
Steps to reproduce
Run the setup for this project
Create a component that uses any type of hook in it (useState, useEffect, etc)
Build the library (yarn build) and then import it into another local project. I used yarn link for my current project.
Expected behavior
I can add hooks to my component library and import them just like any other component library
Actual behavior
When I remove the hooks from my component library, and just use a simple component (something that renders a <div />), it works perfectly. But as soon as I add a useState to the component, it breaks the project it's imported into.
However, in my local demo package and through the tests, it works just fine.
Run yarn test to see the e2e and unit tests that everything works great
Run yarn build
Then run yarn link
Create a brand new app with create react app.
Go to any component and import import { DragSelection } from 'react-drag-and-select/build'
Add it to the component (<DragSelection></DragSelection>). Save and refresh the project build and see this error:
Additional context
What's really odd is that everything works when I don't include hooks. In the project I was importing the library into, we are using the same react and react-dom versions (^16.10.2) and I have them set as peerDependencies and devDependencies in the library. The moment I include some sort of hook logic, it breaks. This project I'm importing this library into has hooks all over the place too.
Describe the bug First off, I'd like to say thanks for putting together such a great library. I hit the ground running with this. Was super excited to see you added the TypeScript documentation as well.
This is similar to https://github.com/udilia/create-react-library/issues/55 in the sense I get the same error but I'm getting it without using rollup - just using the out-of-the-box configuration with the project (except I've added TypeScript).
System
Node.js version:
11.15.0
NPM or Yarn version: Yarn1.19.1
Operating system: Mac OSX MojaveSteps to reproduce
useState
,useEffect
, etc)yarn build
) and then import it into another local project. I usedyarn link
for my current project.Expected behavior
I can add hooks to my component library and import them just like any other component library
Actual behavior
When I remove the hooks from my component library, and just use a simple component (something that renders a
<div />
), it works perfectly. But as soon as I add auseState
to the component, it breaks the project it's imported into.However, in my local demo package and through the tests, it works just fine.
Reproducible demo
yarn start
yarn test
to see the e2e and unit tests that everything works greatyarn build
yarn link
import { DragSelection } from 'react-drag-and-select/build'
<DragSelection></DragSelection>
). Save and refresh the project build and see this error:Additional context
What's really odd is that everything works when I don't include hooks. In the project I was importing the library into, we are using the same
react
andreact-dom
versions (^16.10.2
) and I have them set aspeerDependencies
anddevDependencies
in the library. The moment I include some sort of hook logic, it breaks. This project I'm importing this library into has hooks all over the place too.