Skip to content

alexbeletsky/example-react-app-react-mail

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

40 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ReactMail

An Example React.js App for Practical Learning Purposes

Let me begin by saying that there are many great resources out there for learning React etc...

My goal with this project, is for it to serve as a practical example that goes beyond a basic TODO list.

Contributions, Feedback, and Code Review are welcome! Please, feel free to reach out with any questions, suggestions for improvements, or ideally Issues and/or Pull Requests :)

The App

# Install dependencies
npm install

# Start development servers (client + API)
npm start

# Run tests
npm test

reactmaillistanimation

Some Basic Features/Highlights. Hint: these should become tests :)

  • Fetch data from JSON API (read)
  • Submit data to the JSON API (write)
  • Maintain local state
  • View a listing of messages
    • Text search
    • "Sort by"
    • Filter by "flagged"
    • "Load More" (i.e. pagination)
    • Toggle a message's "flagged" status
    • Delete a message
  • View a single message
    • Toggle a message's "flagged" status
    • Delete a message
    • Navigate directly to /:id route and have appropriate message requested
    • Redirect back to "messages" when /:id is not found OR is deleted
  • Animation via ReactCSSTransitionGroup

React

  • Setup basic routes routes.js
  • Utilize React component lifecycle to initiate our HTTP requests based on entry route

Setting up a React, ES6+, Webpack, Babel Environment

Just kidding. We'll let nwb do all of that for us :)

All you need to know is 2 commands

  • npm install: Install dependencies
  • npm start: Start development server (along w/ hot reloading and all the related goodness)
  • Now you can open your browser to http://localhost:3000/ and you should see the app running

This way we don't get hung up on the myriad of ways we could go about this.

Communicating With a JSON API

Using axios, a Promise based HTTP client, we communicate with a JSON API (powered by json-server) to:

  • Retreive a resource listing (GET /)
    • Work with managing our "query parameters" for pagination, filtering, and search
  • Retreive a single resource (GET /:id)
  • Update a single resource (PATCH /:id)
  • Destroy a single resource (DELETE /:id)

Utility Libraries (embrace open source)

  • lodash general Javascript utility library
  • classsnames to make dynamic HTML classNames more pleasant

Testing

  • Test runner: mocha
  • Assertions (and spies): expect
  • Unit testing React components with shallow rendering Enzyme

Unit tests live directly adjacent to the file under test. Example:

src/some/path/someModule.js
src/some/path/someModule.test.js

Running Tests

  • Run all tests: npm test
  • Run specific tests: npm test -- --grep='some pattern here'
  • Run tests with a watch: npm test -- --watch

Some Visual Highlights

image

image

embracethejsx

About

ReactMail - An Example React.js App for Practical Learning Purposes

Resources

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 93.2%
  • CSS 4.3%
  • HTML 2.5%