Doing a simple tic-tac-toe game. I am trying to get a single cell highlighted on mouse-enter and than back to normal on mouse-leave - using state and inline styling to accomplish that. State changes fine on mouse-enter (so is the styling) however it never sets back to normal on mouse-leave. What am I missing here?
import React, { useState } from 'react';
function Cell(props) {
let defaultStyle = {backgroundColor: 'none'}
let selectedStyle = {backgroundColor: 'blue'}
const [style, setStyle] = useState(defaultStyle)
const sendData = () =>{
props.clicker(props.cords)
}
const set = () =>{
setStyle(selectedStyle);
}
const unset = () =>{
setStyle(defaultStyle);
}
return (
<td onClick = {sendData} onMouseEnter= {set} onMouseLeave = {unset} style ={style}>{props.content}</td>
)
}
export default Cell