Skip to content

Instantly share code, notes, and snippets.

View Monstarrrr's full-sized avatar
🐮
Moo <3

Monstar Monstarrrr

🐮
Moo <3
View GitHub Profile
@Monstarrrr
Monstarrrr / reducer.jsx
Last active April 25, 2022 17:41
Replaced useState() with useReducer() as an example to compare the two.
import React, { useReducer } from 'react'
import nutritivApi from '../Api/nutritivApi'
const reducer = (prevState, action) => {
const { type, key, value } = action;
if(type === 'INPUT') {
return {
...prevState,
inputs: {