-
Notifications
You must be signed in to change notification settings - Fork 9
Open
Description
Steps to Reproduce:
- Clones and installed deps.
- Tested storybook and created build. (Working)
- Tested by installing and importing Button component in new react cra project. (Working)
- Modified the original Button component and added
useState
hook. - Tested component in storybook (Working)
- Created Build (Build created without errors successfully)
- Installed again in CRA project.
- CRA App Crashes after starting. (Not Working)
Expected Behavior:
- Should also work with hooks.
Screenshots:
This issue usually happens when multiple react versions are conflicting.
I also tried removing react
and react-dom
from devDependencies
and only keeping them in peer deps. (Got same error, didn't worked)
Using state in a react button component seems a very basic functionality to me so it should not give any errors. I maybe missing something obvious.
This is the modified code of Button.tsx
component:
import React, { useState } from "react";
import "./Button.scss";
export interface ButtonProps extends React.DetailedHTMLProps<React.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>{
label: string;
}
const Button = ({label, ...others}: ButtonProps) => {
const [state, setState] = useState(label)
return <button {...others} onClick={() => setState("Clicked")}>{state}</button>;
};
export default Button;
Metadata
Metadata
Assignees
Labels
No labels