The Chill Coding Lounge – Telegram
The Chill Coding Lounge
520 subscribers
493 photos
96 videos
11 files
225 links
Welcome to the Coding Lounge, chill and relax as we talk about programming, memes, and the pain of errors.
Download Telegram
useReducer really reducing the remaining brain cells I have in my mind. RIP
Why should you use useReducer (until my dumb ahh reaches Redux😂)

UseReducer is useful when:

Your component has multiple interrelated state variables.

You need to perform several state updates at once (e.g. starting a game resets time, score, level).

State updates are dependent on previous values or other state properties.

You want to centralize and decouple the state logic from your component’s UI logic.

Here is an example:

//Setting Initial State
const initalState: {count:0, step:1}

//Reducer function
function reducer(state, action) {
//return needed in order to update state
switch (action.type) {
case "inc":
return { ...state, count: state.count + state.step };
case "dec":
return { ...state, count: state.count - state.step };
case "setCount":
return { ...state, count: action.payload };
case "setStep":
return { ...state, step: action.payload };
case "reset":
return intialState;
default:
throw new Error("Nope");
}

}


function Test(){
const [state, dispatch] = useReducer(reducerFunction, initialState);

const dec = function () {

//dispatch is the equivalent of setState for useState

dispatch({ type: "dec" });

};

const defineStep = function (e) {
dispatch({ type: "setStep", payload: Number(e.target.value) });
};

return <>YOUR JSX GANG</>
}


Confused yet?😂😂 I can go more into detail if you guys want, just let me know🙏🏾
👍1
How's everyone's day been so far?
2🥰1
Good morning gang! Let's get our bread😎
Cooking something simple but this taught me so much about about useReducer alongside frontend dev. I'm going to change up format of the quiz to better suit this goofy aah channel tho🗣🗣
🔥2
Gang I think I failed🥲 Why did I manage to hurt myself with these emojis😂

(Disclaimer: This was totally done on purpose)
My first ever mini-side project which I created to learn React (specifically useReducer)

While it may be simple, I feel quite happy as I pushed myself out of my comfort zone and somewhat overcame imposter syndrome for it (Dramatic I know but still😂)

Take a look and let me know what you think (React based questions btw)

Also responsive so it should work well on mobile devices.

https://goofy-react-quiz.vercel.app/

(P.S An Easter egg is available, if someone can find it let me know😂😂)
🔥9
Holy mother of node modules, compressing a project takes forever.

And before you say why not push to github, I was asked to provide the actual file 😂
The Chill Coding Lounge
Holy mother of node modules, compressing a project takes forever. And before you say why not push to github, I was asked to provide the actual file 😂
To the people who read this, I would like to formally apologize for my grave stupidity😂😂 I should have not included the node modules. Rookie mistake🙏🏾
🤣1
Good morning guys🫡
I'm cooking something down right deep. Will release it in a few
After my last article, I decided to write on something that I personally struggle with and that is self-sabotage. There a lot of roots behind it, but I think it's something a lot of us feel from time to time.

I tried to keep it as witty and in true tomfoolery fashion but I want to also keep it as real as possible. Take a look for yourself and hopefully you leave with something impactful.

https://medium.com/@henok.y2014/the-absurdity-of-self-sabotage-60ce8e23836e

#article @thechillcodinglounge
4👍1
The Chill Coding Lounge pinned «After my last article, I decided to write on something that I personally struggle with and that is self-sabotage. There a lot of roots behind it, but I think it's something a lot of us feel from time to time. I tried to keep it as witty and in true tomfoolery…»
Vite time babyyyyyyyyyyyyyy
🔥3
Chest day with this 👌
Good Morning gang! We've made it to Friday🙏🏾
👍1
Random mission: Write the most random thing in the comment below (engagement-bait🥀)