DimiMikadze / create-react-library

React NPM library starter kit based on Facebook's create react app
MIT License
602 stars 60 forks source link

React Hooks don't work #55

Closed felixrigau closed 5 years ago

felixrigau commented 5 years ago

I'm trying to create and export a React component using useState() React hook, but the example application that imports the exported component by the library doesn't work.

react hooks

I just generated the project using the default settings, so the package.json files and the rollup.config.js were generated by "create-react-library" (none modifications).

I've created this small component as an example:

import React, { useState } from 'react';

function SimpleComponent(){
    const [counter, setcounter] = useState(0)
    return (
        <div onClick={() => setcounter(counter => counter + 1)}>
            {counter}
        </div>
    )
}

Any idea how to fix it? Thanks!

DimiMikadze commented 5 years ago

@felixrigau you're opening an issue in a different repository, we are not using rollup.

dwilt commented 5 years ago

I'm also running into this as well. I created a component, imported it into another project via yarn link and am seeing this.

dwilt commented 5 years ago

I believe this is because this starter kit is not handling multiple versions of React correctly. I have a component that is working (with hooks) inside of my library repo but I get this error when I use it inside of another project (built with create react app). I'm pretty sure there is some config/dependency issue with webpack