Quantcast
Channel: Active questions tagged react-native+typescript - Stack Overflow
Viewing all articles
Browse latest Browse all 6287

Using React how to append to a string every time a checkbox is checked and display in another input text field

$
0
0

I want to update a text input field every time a checkbox is checked(true). Can someone please advise how can this be done please?.

I'm trying to click a checkbox and update another input field. Every time the checkbox is checked I want to add the date to a string.

Currently, my string value is being overwritten by the new value. I want it to be a string and not an array.

const [checkboxCheckedTrue, setCheckboxStatus] = useState(false); const [updateMyMsg, setmyMsg] = React.useState("");  useEffect((): void => {    if (checkboxCheckedTrue) {      var a = new Date();      const myMsg = "My Date is" + a;      setmyMsg(myMsg );    }  });

My expected string should look like the following:

"Thu Sep 15 2022 15:52:41 <br/> Thu Sep 15 2022 15:52:41 <br/> Thu Sep 15 2022 15:52:41"

Viewing all articles
Browse latest Browse all 6287

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>