From c5788a00d20bb8f319d6925a83ca5524e808f56e Mon Sep 17 00:00:00 2001 From: cami Date: Wed, 21 Jul 2021 21:33:16 +0200 Subject: [PATCH] Forceupdate things --- frontend/src/components/pages/Study.js | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/frontend/src/components/pages/Study.js b/frontend/src/components/pages/Study.js index 94d825d..7e860bb 100644 --- a/frontend/src/components/pages/Study.js +++ b/frontend/src/components/pages/Study.js @@ -1,4 +1,4 @@ -import React, { useEffect } from "react"; +import React, { useEffect, useState } from "react"; import "../../App.css"; import Footer from "../../Footer"; import InputField from "../InputField"; @@ -8,6 +8,12 @@ import BehaviorStudyInfo from "../BehaviorStudyInfo"; import BehaviorNormal from "../BehaviorNormal"; import { Button } from "../Button"; +//create your forceUpdate hook +function useForceUpdate() { + const [value, setValue] = useState(0) + return () => setValue(value => value +1) +} + export default function Study() { let username = ""; const setUsername = (tmp_username) => { @@ -29,6 +35,8 @@ export default function Study() { isStepNormal = tmp; }; + const forceUpdate = useForceUpdate(); + let logger = new Logger({ //inputs: ["cursor", "wheel", "keyboard", "touch"], inputs: ["keyboard"], @@ -64,11 +72,13 @@ export default function Study() { const handleIsStepStart = () => { setIsStepStart(false); - console.log("isStepStar", isStepStart) + console.log("isStepStar", isStepStart); setIsStepNormal(true); - console.log("isStepStar", isStepNormal) + console.log("isStepNormal", isStepNormal); + forceUpdate(); }; + const onSubmitClick = (e) => { e.preventDefault(); let opts = { @@ -152,6 +162,7 @@ export default function Study() { ) : null} +