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

Adding "checked" property as new "otherprop" #228

Merged
merged 4 commits into from
Aug 20, 2024

Conversation

LourdesRsdp
Copy link
Collaborator

-Checked allowed in Toggle, Checkbox and Radiobutton components
-Also, cleaned up some files by removing console.log statements

Closes #197

-Checked allowed in Toggle, Checkbox and Radiobutton components
-Also, cleaned up some files by removing console.log statements

const handleClick = () => {
setIsOn(!isOn);
};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you don't need isOn, setIsOn useState (we use the useState approach when we need to do a conversion, like in the Text property that get's converted into e.g. a list of items)

You can directly read the value from OtherProps and use the context to update it.

like in: https://github.com/Lemoncode/quickmock/blob/main/src/common/components/front-basic-sapes/rectangle-basic-shape.tsx

    const fill = useMemo(
      () => otherProps?.backgroundColor ?? 'white',
      [otherProps?.backgroundColor]
    );
        <Rect
          x={0}
          y={0}
          width={restrictedWidth}
          height={restrictedHeight}
          strokeWidth={2}
          stroke={stroke}
          fill={fill}
          cornerRadius={5}
        />

@brauliodiez brauliodiez merged commit fe62254 into main Aug 20, 2024
1 check passed
@brauliodiez brauliodiez deleted the feature/-#197-boolean-prop-checked branch August 20, 2024 17:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add a new prop (boolean) Checked to be used in toggle, checkbox, radiobutton
2 participants