Skip to content

Commit

Permalink
Change import statements, and add type for SwitchProps (#1093)
Browse files Browse the repository at this point in the history
* Change import statements, and add type for SwitchProps

* Add space to argument of offImg in Switch.tsx
  • Loading branch information
tylerdtran authored Oct 27, 2023
1 parent 04ac251 commit cb1856e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/components/common/Switch.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { shallow } from 'enzyme';
import React from 'react';
import Switch from './Switch.js';
import Switch from './Switch.tsx';

const switchOnClass = '.switch-body.switch-on'; // there has to be a better way of doing this
const switchCheckboxClass = '.switch-input';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,14 @@ import '../../styles/Switch.scss';
* @param {JSX} onImg (optional): (JSX) element to be displayed on switch body when set to "on"
* @param {JSX} offImg (optional): (JSX) element to be displayed on switch body when set to "off"
*/
interface SwitchProps {
on: boolean;
onToggle: (on:boolean) => void;
onImg?: JSX.Element;
offImg?: JSX.Element;

const Switch = function (props) {
}
const Switch = function (props: SwitchProps) {
const [on, setOn] = useState(!props.on ? false : props.on);

useEffect(() => {
Expand Down

0 comments on commit cb1856e

Please sign in to comment.