Skip to content

Instantly share code, notes, and snippets.

@patwadeepak
Created July 23, 2021 03:38
Show Gist options
  • Save patwadeepak/23b8018175f9b3dc7fda8df5b771ada4 to your computer and use it in GitHub Desktop.
Save patwadeepak/23b8018175f9b3dc7fda8df5b771ada4 to your computer and use it in GitHub Desktop.
Pure React Way - App.js
import Posts from "./Components/Posts";
import PostForm from "./Components/PostForm";
import { useState } from "react";
const App = () => {
const [PostData, setPostData] = useState([]);
const addPost = (formData) => {
setPostData([formData, ...PostData]);
};
return (
<div className="app-container">
<h1> Pure React Way</h1>
<PostForm addPost={addPost} />
<Posts setPostData={setPostData} PostData={PostData} />
</div>
);
};
export default App;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment