Created
May 22, 2023 19:30
-
-
Save mansha99/a465d37a573919c1b2e46fc8e2fde0fe to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"use client"; | |
import { useReducer } from "react"; | |
import { fanSpeedInitial, fanSpeedReducer } from "./page-reducer"; | |
export default function Home() { | |
const [fanSpeedCurrent, fanSpeedHandler] = useReducer(fanSpeedReducer, fanSpeedInitial); | |
return ( | |
<main style={{ padding: 20 }}> | |
<div> | |
<h3>Hello Reducer</h3> | |
<div style={{padding:20}}> | |
Fan Status is <b> {fanSpeedCurrent.status}</b> and Level is | |
<b> {fanSpeedCurrent.level}</b> | |
</div> | |
<div> | |
<button onClick={() => fanSpeedHandler({ type: 'ROTATE_LEFT' })}>Rotate Left</button> | |
| |
<button onClick={() => fanSpeedHandler({ type: 'ROTATE_RIGHT' })}>Rotate Right</button> | |
</div> | |
</div> | |
</main> | |
) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment