+export const BasicUsage = () => {
+ const [checked, setChecked] = useState(false);
+ return (
+
- >
-);
+ );
+};
+
+export const RadioDisabled = () => {
+ const [checked, setChecked] = useState(false);
+
+ return (
+
+ );
+};
+
+export const LabelDisabled = () => {
+ const [checked, setChecked] = useState(false);
-export const RadioCellRTL = () => (
- <>
-
-
|
+ return (
+
+
+ setChecked(!checked)}
+ />
+
- >
-);
+ );
+};
+
+export const RadioColor = () => {
+ const [checked, setChecked] = useState(false);
+
+ return (
+
+
+ setChecked(!checked)}
+ />
+
+
+ );
+};
+
+export const OnClick = () => {
+ const [checked, setChecked] = useState(false);
+
+ return (
+
+
+ {
+ setChecked(!checked);
+ alert(checked);
+ }}
+ />
+
+
+ );
+};
+
+export const RadioCell = () => {
+ const [checked, setChecked] = useState(false);
+
+ return (
+ <>
+
+ setChecked(!checked)
+ }}
+ />
+ |
+ >
+ );
+};
+
+export const RadioCellRTL = () => {
+ const [checked, setChecked] = useState(false);
+
+ return (
+ <>
+
+ setChecked(!checked)
+ }}
+ />
+ |
+ >
+ );
+};
diff --git a/src/components/Radio/index.tsx b/src/components/Radio/index.tsx
index b1c3247ad..b8606b2c1 100644
--- a/src/components/Radio/index.tsx
+++ b/src/components/Radio/index.tsx
@@ -1,4 +1,4 @@
-import React, { MouseEvent, useEffect, useState } from 'react';
+import React, { MouseEvent } from 'react';
import classnames from '../../utils/classNames';
import Icon from '../Icons';
@@ -15,31 +15,23 @@ const Radio = ({
labelDisabled,
checkedColor,
onClick,
- onChange,
rtl,
label = 'radio button'
}: IProps) => {
- const [isChecked, setChecked] = useState(checked);
const handleClick = (event: MouseEvent): void => {
if (!labelDisabled) {
- setChecked(!isChecked);
onClick && onClick(event);
}
};
const handleRadioClick = (event: MouseEvent): void => {
if (labelDisabled) {
- setChecked(!isChecked);
onClick && onClick(event);
}
};
- useEffect(() => {
- onChange && onChange(isChecked);
- }, [isChecked]);
-
- const iconName = isChecked ? 'checked' : 'circle';
- const iconColor = disabled ? '#c8c9cc' : isChecked ? checkedColor : '#000';
+ const iconName = checked ? 'checked' : 'circle';
+ const iconColor = disabled ? '#c8c9cc' : checked ? checkedColor : '#000';
// TODO: Add form related inputs here when working on form element
return (
diff --git a/src/components/Radio/types.ts b/src/components/Radio/types.ts
index a5946377e..6606805f5 100644
--- a/src/components/Radio/types.ts
+++ b/src/components/Radio/types.ts
@@ -1,12 +1,11 @@
export interface IProps {
name?: string;
disabled?: boolean;
- checked?: boolean;
+ checked: boolean;
labelDisabled?: boolean;
rtl?: boolean;
iconSize?: string;
checkedColor?: string;
- onClick?: Function;
- onChange?: Function;
+ onClick: Function;
label?: string;
}