Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not working with hooks #45

Closed
MrBartusek opened this issue Dec 13, 2022 · 3 comments
Closed

Not working with hooks #45

MrBartusek opened this issue Dec 13, 2022 · 3 comments
Labels
question Further information is requested

Comments

@MrBartusek
Copy link

Hey, adding hooks to this example does't work.

Chage Example.tsx to:

import React, { useState } from 'react';

export type ExampleProps = {
  text?: String;
};

export function Example(props: ExampleProps) {
  const [state, setState] = useState(false);

  return <div>{props.text}</div>;
}

image

@TimMikeladze
Copy link
Owner

TimMikeladze commented Dec 13, 2022

Hi @MrBartusek I'm not able to reproduce this locally. I added a hook to the example and pushed it to Github. It builds successfully in the CI environment too. https://github.com/TimMikeladze/tsup-react-package-starter/actions

I've seen this error before but in a specific case: I was using npm link or yarn link to include a package I was developing locally in a different React project.

If this is indeed the case for you, then I suggest using https://github.com/wclr/yalc to handle the package linking process. This workaround solved this error for me and furthermore improved my overall development workflow since I started using yalc to manage my local packages.

As part of debugging I suggest you delete your node_modules and yarn.lock file and then running yarn again.

@TimMikeladze TimMikeladze added the question Further information is requested label Dec 13, 2022
@MrBartusek
Copy link
Author

To be completely honest with you @TimMikeladze this single comment fixed all of the issues that I've been trying to resolve for a total of 18 hours (tracked by waketime). I've tried multiple tutorials, templates, webpack, babel, tsup, rollup and even some cursed stuff like build scripts or vite. The whole issue, as you have pointed out, was caused by links or other obscure importing methods. I've just published a package to npm and imported it straight from it, without messing with it locally. It works like a charm. Thank you so much, I can finally get some good sleep.

@TimMikeladze
Copy link
Owner

@MrBartusek I am uplifted to hear that! I felt the same way when I stumbled upon a comment suggesting yalc, everything just worked afterwards 😄.

In fact this comment made me realize that yalc should be added into this starter kit. I will do that shortly.

Happy coding and glad I could help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants