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 …


This content originally appeared on DEV Community 👩‍💻👨‍💻 and was authored by ReactJS Guru

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


This content originally appeared on DEV Community 👩‍💻👨‍💻 and was authored by ReactJS Guru


Print Share Comment Cite Upload Translate Updates
APA

ReactJS Guru | Sciencx (2022-12-26T06:27:31+00:00) How to Make Subreddit Feed App in React JS. Retrieved from https://www.scien.cx/2022/12/26/how-to-make-subreddit-feed-app-in-react-js/

MLA
" » How to Make Subreddit Feed App in React JS." ReactJS Guru | Sciencx - Monday December 26, 2022, https://www.scien.cx/2022/12/26/how-to-make-subreddit-feed-app-in-react-js/
HARVARD
ReactJS Guru | Sciencx Monday December 26, 2022 » How to Make Subreddit Feed App in React JS., viewed ,<https://www.scien.cx/2022/12/26/how-to-make-subreddit-feed-app-in-react-js/>
VANCOUVER
ReactJS Guru | Sciencx - » How to Make Subreddit Feed App in React JS. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2022/12/26/how-to-make-subreddit-feed-app-in-react-js/
CHICAGO
" » How to Make Subreddit Feed App in React JS." ReactJS Guru | Sciencx - Accessed . https://www.scien.cx/2022/12/26/how-to-make-subreddit-feed-app-in-react-js/
IEEE
" » How to Make Subreddit Feed App in React JS." ReactJS Guru | Sciencx [Online]. Available: https://www.scien.cx/2022/12/26/how-to-make-subreddit-feed-app-in-react-js/. [Accessed: ]
rf:citation
» How to Make Subreddit Feed App in React JS | ReactJS Guru | Sciencx | https://www.scien.cx/2022/12/26/how-to-make-subreddit-feed-app-in-react-js/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.