DEV Community

Cover image for How to Make Subreddit Feed App in React JS
ReactJS Guru
ReactJS Guru

Posted on • Originally published at reactjsguru.com

 

How to Make Subreddit Feed App in React JS

In this article, we will make Subreddit feed App in React JS. Basically, we will have an application where we will get Subreddit feed list from specific Subreddit. This app will fetch all the post list along with header, also as new post will be added so that post also will be visible in here, so it will be dynamic.

Here, we are going to use Reddit’s API to fetch the posts list of any particular Subreddit. This will be very easy to make, so let’s build this step-by-step.

Pre-requisites to Make Subreddit Feed App in React JS

  • Basic knowledge of React.
  • Basic knowledge of React components.
  • Basic knowledge of Hooks.

Adding Basic Structure and States

Okay, let’s move to our App.js component, in here we have imported useState hook and also Article component where we will do something later. Now in App function, we have added article and subreddit states with some default value, then in return statement we have added a header tag where we have an input field which value will be state. And also if we change the value of input then we will set state with that value. Lastly, we have added a div for articles.

`import React, { useState, useEffect } from 'react';

import Article from './components/Article';

function App() {
const [articles, setArticles] = useState([]);
const [subreddit, setSubreddit] = useState('gaming');

return (



setSubreddit(e.target.value)} value={subreddit} />




);
}

export default App;`

Read More

Top comments (0)

Top Posts from the React Ecosystem

1. Changes In The Official React Documentation

The former React Docs Beta has been officially released as the updated React documentation at react.dev after years of hard work and refinement. Check out the brand new React Docs: What’s New in the Updated React Docs

2. CRA's Time is Over

React developer team has removed create-react-app (CRA) from official documentation rendering it no longer the default setup method for new projects. The bulky setup, slow, and outdated nature of CRA led to its removal: create-react-app is officially dead

3. How to Fetch Dev.to Articles for Your Portfolio

Integrate the articles of your Dev.to profile into your personal portfolio with either React, Vue, or Next.js by following these simple steps. It outlines how to include frontend to pull the information and correctly utilizes the Dev.to API: How to Fetch Your Dev.to Articles for Your Portfolio with React