DEV Community

Banele1999
Banele1999

Posted on

Learn React with me

Today I start "The Ultimate React Course 2024: React, Redux & More" by Jonas Schmedtmann on Udemy. I will share a detailed blog post on everything I learned in the course.
Image description

import { useEffect, useState } from "react";

export default function App() {
  const [advice, setAdvice] = useState("");
  const [count, setCount] = useState(0);

  useEffect(function () {
    getAdvice();
  }, []);

  async function getAdvice() {
    const res = await fetch("https://api.adviceslip.com/advice");
    const data = await res.json();
    setAdvice(data.slip.advice);
    setCount((a) => a + 1);
  }

  return (
    <div>
      <h1>{advice}</h1>
      <button onClick={getAdvice}>Get Advice</button>
      <Message count={count} />
    </div>
  );
}

function Message(props) {
  <p>
    You have read <strong>{props.count}</strong> pieces of advice
  </p>;
}
_**

#### 


**_
Enter fullscreen mode Exit fullscreen mode

Top comments (5)

Collapse
 
brense profile image
Rense Bakker

Don't learn redux. If you want to learn state management in client-side rendered SPAs, learn something like Jotai or Zustand, but tbh managing global state on the client is no longer necessary since server-side rendering and react server components let you fetch the data you need on the server, without doing round trips and making a giant redux store on the client.

Collapse
 
banele1999 profile image
Banele1999

Thank you. I will look into that

Collapse
 
np03a170120 profile image
Season Shrestha

Can you also please, keep explanations. I want to learn too. Happy learning ❤️

we can stay connected, share learning
https://www.linkedin.com/in/season-shrestha-b11125207?utm_source=share&utm_campaign=share_via&utm_content=profile&utm_medium=ios_app

Collapse
 
banele1999 profile image
Banele1999

Hey.
I followed you on linkedin. Looking forward to learning with you
linkedin.com/in/banelempofu/

Collapse
 
random_ti profile image
Random

🔥💖