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)