Refactoring..
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is passing

This commit is contained in:
cami 2021-07-21 21:53:57 +02:00
parent c5788a00d2
commit cf481d42e1

View file

@ -8,13 +8,21 @@ import BehaviorStudyInfo from "../BehaviorStudyInfo";
import BehaviorNormal from "../BehaviorNormal"; import BehaviorNormal from "../BehaviorNormal";
import { Button } from "../Button"; import { Button } from "../Button";
//create your forceUpdate hook
function useForceUpdate() {
const [value, setValue] = useState(0)
return () => setValue(value => value +1)
}
export default function Study() { export default function Study() {
var [logger, setLogger] = useState();
useEffect(() => {
logger = new Logger({
//inputs: ["cursor", "wheel", "keyboard", "touch"],
inputs: ["keyboard"],
// apiUrl: "https://behavior.marcocamenzind.ch",
apiUrl: "http://localhost:5000",
logToConsole: true,
});
logger.init();
}, []);
let username = ""; let username = "";
const setUsername = (tmp_username) => { const setUsername = (tmp_username) => {
username = tmp_username; username = tmp_username;
@ -25,6 +33,7 @@ export default function Study() {
password = tmp_password; password = tmp_password;
}; };
/*
let isStepStart = true; let isStepStart = true;
const setIsStepStart = (tmp) => { const setIsStepStart = (tmp) => {
isStepStart = tmp; isStepStart = tmp;
@ -34,18 +43,11 @@ export default function Study() {
const setIsStepNormal = (tmp) => { const setIsStepNormal = (tmp) => {
isStepNormal = tmp; isStepNormal = tmp;
}; };
*/
const forceUpdate = useForceUpdate(); const [isStepStart, setIsStepStart] = useState(true);
const [isStepNormal, setIsStepNormal] = useState(false);
let logger = new Logger({
//inputs: ["cursor", "wheel", "keyboard", "touch"],
inputs: ["keyboard"],
// apiUrl: "https://behavior.marcocamenzind.ch",
apiUrl: "http://localhost:5000",
logToConsole: true,
});
logger.init();
const handleLoggerOff = () => { const handleLoggerOff = () => {
logger.stop(); logger.stop();
@ -75,10 +77,9 @@ export default function Study() {
console.log("isStepStar", isStepStart); console.log("isStepStar", isStepStart);
setIsStepNormal(true); setIsStepNormal(true);
console.log("isStepNormal", isStepNormal); console.log("isStepNormal", isStepNormal);
forceUpdate(); // forceUpdate();
}; };
const onSubmitClick = (e) => { const onSubmitClick = (e) => {
e.preventDefault(); e.preventDefault();
let opts = { let opts = {
@ -103,17 +104,6 @@ export default function Study() {
}); });
}; };
/*
useEffect(() => {
if (isStepStart) {
handleIsStepStart();
console.log("useEffect; normal");
} else if (isStepNormal) {
console.log("useEffect; normal");
}
});
*/
return ( return (
<> <>
<div className="sitePage"> <div className="sitePage">