How can I use react hooks to take a time on stopwatch and put it into database using axios

Viewed 52

I need help ,I m new in react how can I use react hooks to take a time on stopwatch and put it into database using axios I use react-stopwatch npm https://www.npmjs.com/package/react-stopwatch The code


import * as React from 'react';
import ReactStopwatch from 'react-stopwatch';
 
const Stopwatch = () => (
  <ReactStopwatch
    seconds={0}
    minutes={0}
    hours={0}
    limit="01:00:10"
    onChange={({ hours, minutes, seconds }) => {
      // do something
    }}
    onCallback={() => console.log('Finish')}
    render={({ formatted, hours, minutes, seconds }) => {
      return (
        <div>
          <p>
            Formatted: { formatted }
          </p>
          <p>
            Hours: { hours }
          </p>
          <p>
            Minutes: { minutes }
          </p>
          <p>
            Seconds: { seconds }
          </p>
        </div>
      );
    }}
   />
);
 
export default Stopwatch;

1 Answers

Just store the value or time at which the stopwatch stops in the state and make a backend api using node js or any other technology you like and post that data in that endpoint to store it in the database

Related