1import React from "react";
2import Switch from "@material-ui/core/Switch";
3
4export default function MaterialuiSwitch() {
5
6 const [state, setState] = React.useState(false);
7
8 function handleSwitchChange (e) {
9 setState(e.target.checked);
10 // Add actions here for when the switch is triggered
11 };
12
13 var text;
14
15 if (state) {
16 text = 'on';
17 } else {
18 text = 'off';
19 };
20
21 return (
22 <div>
23 {text}
24 <Switch
25 checked={state}
26 onChange={handleSwitchChange}
27 color="primary"
28 />
29 </div>
30 );
31};