This is a simple social media app built with React, where users can create posts, view existing posts, and delete posts.
Component responsible for creating new posts. It includes a form with fields for userId, post title, post content, number of views, and tags. Upon submission, it sends a POST request to https://dummyjson.com/posts/add
to add the post to the backend.
Context provider component that manages the state of postList
, which stores all posts fetched from the backend. It also manages the fetching
state to indicate when posts are being loaded. The provider uses useReducer
to handle actions like adding a post, deleting a post, and initializing posts.
Component that renders a list of posts fetched from the PostListProvider
context. It displays a loading indicator while posts are being fetched (fetching
is true) and a welcome message when no posts are available. Each post is rendered using the Post
component.
Component that renders an individual post with its title, content, tags, and number of views. It includes a delete button (MdDelete
icon) to delete the post. Uses the deletePost
function from the PostList
context to delete posts.
To run this application locally:
-
Clone the repository:
git clone https://github.com/rishibharadwajsai/social-media-app.git cd social-media-app
-
Install dependencies:
npm install
-
Start the development server:
npm run dev
-
Open your browser and navigate to
http://localhost:5173
to view the app.
- React: Used for building the UI components.
- react-icons (specifically
MdDelete
): Provides icons for delete functionality. - Bootstrap (assumed from classes like
form-control
,btn
, etc.): For styling UI components.
Contributions are welcome! If you find any issues or have suggestions for improvements, please open an issue or a pull request.
This project is licensed under the MIT License - see the LICENSE file for details.