An Interest In:
Web News this Week
- March 20, 2024
- March 19, 2024
- March 18, 2024
- March 17, 2024
- March 16, 2024
- March 15, 2024
- March 14, 2024
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 Reddits API to fetch the posts list of any particular Subreddit. This will be very easy to make, so lets 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, lets 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;`
Original Link: https://dev.to/reactjsguru/how-to-make-subreddit-feed-app-in-react-js-42kc
Dev To
An online community for sharing and discovering great ideas, having debates, and making friendsMore About this Source Visit Dev To