john-smilga / react-vite-projects-3-reviews

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Steps

Import Reviews

First, import the reviews data into your project. This data should be an array of objects, with each object representing a person's review and containing properties such as name, job, image URL, and text.

Setup State Value

Next, set up the reviews data as a state variable using the useState hook. This will allow you to modify the data and have those changes automatically reflected in the rendered output.

React Icons (Optional)

Docs

Render First Person

To render the first person in the list, you can access the first item in the reviews array and use its properties to display the person's image (inline styles), name, job, and review text.

Prev and Next

To allow the user to cycle through the reviews, you can set up buttons to display the next and previous reviews in the list. You can do this by keeping track of the current index in the reviews array, and updating the index when the user clicks the next or previous button. You can then use the updated index to access the corresponding person's review from the reviews array.

Random

To allow the user to display a random person's review, you can set up a button with functionality to randomly select an index in the reviews array. You can then use the selected index to display the corresponding person's review.

Overall, the flow of the application should look something like this:

  • Import the reviews data into your project as an array of objects.
  • Set up the reviews data as a state variable using the useState hook.
  • Render the first person's review in the list using their image, name, job, and text properties.
  • Set up buttons to display the next and previous reviews in the list. Keep track of the current index in the reviews array and update it when the user clicks the next or previous button.
  • Set up a button to display a random person's review. This button should select a random index in the reviews array and use it to display the corresponding person's review.

About


Languages

Language:CSS 51.9%Language:JavaScript 45.1%Language:HTML 2.9%