import { useSelector, shallowEqual } from "react-redux"; const useClock = () => { return useSelector( (state) => ({ lastUpdate: state.lastUpdate, light: state.light, }), shallowEqual, ); }; const formatTime = (time) => { // cut off except hh:mm:ss return new Date(time).toJSON().slice(11, 19); }; const Clock = () => { const { lastUpdate, light } = useClock(); return (
{formatTime(lastUpdate)}
); }; export default Clock;