Skip to content

Commit

Permalink
fix: add checked to checkbox/toggle interface
Browse files Browse the repository at this point in the history
  • Loading branch information
lottamus committed Jan 28, 2019
1 parent 52b9eaa commit b33ec37
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/Checkbox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export const Checkbox: FunctionComponent<ICheckbox> = props => {
const { id, disabled: isDisabled, onChange, ...rest } = props;

const [checked, setValue] = useState<boolean>(props.checked || false);
const isChecked = props.hasOwnProperty('checked') ? props.checked : checked;
const isChecked = props.hasOwnProperty('checked') ? props.checked || false : checked;

const css = checkboxStyles({ isDisabled, isChecked });

Expand Down Expand Up @@ -44,6 +44,7 @@ export const Checkbox: FunctionComponent<ICheckbox> = props => {

export interface ICheckboxProps {
id: IBox['id'];
checked?: boolean;
onChange?: (checked: boolean) => void;
}

Expand Down
3 changes: 2 additions & 1 deletion src/Toggle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export const Toggle: FunctionComponent<IToggle> = props => {
const { id, disabled: isDisabled, onChange, ...rest } = props;

const [checked, setValue] = useState<boolean>(props.checked || false);
const isChecked = props.hasOwnProperty('checked') ? props.checked : checked;
const isChecked = props.hasOwnProperty('checked') ? props.checked || false : checked;

const css = toggleStyles({ isDisabled, isChecked });

Expand Down Expand Up @@ -64,6 +64,7 @@ export const Toggle: FunctionComponent<IToggle> = props => {
};

export interface IToggleProps {
checked?: boolean;
onChange?: (checked: boolean) => void;
}

Expand Down

0 comments on commit b33ec37

Please sign in to comment.