React chess clock
npm install react-chess-clock> React chess clock hook provides players informations & clock status to let you build the chess clock interface you want.
 
``bash`
npm install --save react-chess-clock
`jsx
import React from 'react'
import useChessClock from 'react-chess-clock'
const App = () => {
const initialTimer = 6000 // 10 minutes
const increment = 5 // optionnal
const [players, clock] = useChessClock(initialTimer, increment)
const {
white,
black
} = players;
const {
activePlayer,
isActive,
isPaused,
start,
toggle,
pause,
reset
} = clock;
return (
Initial timer : {initialTimer}
Increment : {increment}
Active Player : {activePlayer ?? 'none'}
White player turns : {white.turn}
Black player turns : {black.turn}
White timer : {white.timer}
Black timer : {black.timer}
export default App
`
> Players object provides you informations about white and black player
`js`
players = {
white: {
name,
isActive,
isPaused,
timer,
turn
},
black: {
name,
isActive,
isPaused,
timer,
turn
}
}
> Clock object provides you informations about clock status & functions to interact with the clock
`js
clock = {
//Informations
activePlayer
isActive
isPaused
//Functions
start
toggle
pause
reset
}
``
MIT © exrol