Skip to content

Instantly share code, notes, and snippets.

@mansha99
Created May 22, 2023 19:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mansha99/a465d37a573919c1b2e46fc8e2fde0fe to your computer and use it in GitHub Desktop.
Save mansha99/a465d37a573919c1b2e46fc8e2fde0fe to your computer and use it in GitHub Desktop.
"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>&nbsp;{fanSpeedCurrent.status}</b> and Level is
<b>&nbsp;{fanSpeedCurrent.level}</b>
</div>
<div>
<button onClick={() => fanSpeedHandler({ type: 'ROTATE_LEFT' })}>Rotate Left</button>
&nbsp;&nbsp;&nbsp;
<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