https://github.com/thinkswan/react-comments
A React app that allows visitors to post comments.
https://github.com/thinkswan/react-comments
express javascript react tutorial
Last synced: about 1 year ago
JSON representation
A React app that allows visitors to post comments.
- Host: GitHub
- URL: https://github.com/thinkswan/react-comments
- Owner: thinkswan
- License: mit
- Created: 2019-06-28T08:55:50.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2019-06-28T08:55:59.000Z (almost 7 years ago)
- Last Synced: 2025-01-03T19:24:06.835Z (about 1 year ago)
- Topics: express, javascript, react, tutorial
- Language: JavaScript
- Size: 14.6 KB
- Stars: 0
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# react-comments
A React app that allows visitors to post comments.
Based on the tutorial found at
http://facebook.github.io/react/docs/tutorial.html.
## How to use
```
git clone git@github.com:thinkswan/react-comments.git
mv comments.json-example comments.json
npm install
npm start
```
This will start a server at http://localhost:5000/.
## How it works
The server (`server.js`) runs an Express app that exposes two routes:
1. `GET /comments.json`: Parse the `comments.json` file and render its contents
1. `POST /comments.json`: Write a new comment to the `comments.json` file
The client (`public/js/app.js`) is a React app that polls for changes to the
`comments.json` file on the server and updates the UI via React's `setState()`
method.
State is maintained by storing previous comments in the `comments.json` file.
## License
MIT