Giter VIP home page Giter VIP logo

simple-react-app's Introduction

simple-react-app

forthebadge

But you still get it.

Simple base app with react, react-router v4, hot-reload & sass.

npm i -g simple-react-app to install the package.

simple-react-app folderName to start the boilerplate into folderName folder.

Or if you're using [email protected] or above, you can simply run npx simple-react-app folderName, without the need to install the package globally.

What is this

This is a base project that you can use to jumpstart your react apps, it works similarly to create-react-app, just install the package globally and use it to create as many projects as you want (check How to install for detailed instructions). It includes the last react spec as of today 01/03/2018, and uses react-router v4 to handle routes. Style is handled by sass/scss, Bundle is generated with webpack 4. NB: this is just front end, you can use whatever backend language you are most comfortable with.

How to install

You can use both npm or yarn, the version I used to create this project are:

$ node -v ; npm -v ; yarn -v
v8.8.1
5.4.2
1.2.1

If you just freshly installed yarn/npm you are good to go, else you might need to upgrade, for npm I use n

npm install -g n

to install it and after that select at least the stable version (what I used).

n stable

and now you have the latest stable version of node&npm.

npm i -g simple-react-app to install this package globally, from there you will be able to jumpstart as many boilerplates as you wish.

simple-react-app folderName to create a react boilerplate on the folderName folder. By default all dependencies are already installed, just cd folderName and start hacking.

yarn start/npm start to start dev server with hot reload, it's live on localhost:3000.

yarn run build/npm run build to build prod bundle, it includes both treeshaking and uglify to optimize the code as much as possible.

yarn test/npm test run the tests with Jest and Enzyme, by default the test included only check for the correct render of base components & routes, all are passing.

Project structure

The boilerplate structure and files are the same as this repo minus the bin folder, everything else is exactly the same.

*root*
|
├── */src/*
│   ├── */assets/* where images and stuff are stored
│   ├── */containers/* react-router jsx pages
│   ├── *App.jsx* main layout
│   ├── *Routes.jsx* front-end routes
│   ├── *index.html* entry point
│   ├── *index.jsx* javascript entry point
│   ├── *style.scss* styling
│   └── */tests/* contains test environment (Jest + Enzyme)
│       ├── */__mock__/* contains setup to provide a valid path for imports
│       ├── */_tests__/* the actual tests
│       └── *setup.js* setup for enzyme for react 16
├── *package.json* the whole package.json with every dependency and script, nothing is kept hidden
├── *.eslintrc* eslint config
├── *.babelrc* babel config (polyfills)
├── *webpack.config.js* webpack config, it has a dev and prod environment
└── *README.md* this file

Tests

The testing environment is written in Jest and Enzyme. The included tests are very basic and only check the proper render of base components + routes, there are no snapshot tests, I did not feel they were needed being the components really basic, at the first change they would need to be updated, imho setting the wrong approach of "hey tests are broken, let's regenerate snapshots again". While still basic, the default tests are easy to manage and expand, providing a smoother curve into testing with JavaScript and React.

Eslint

This project uses AirBnB Javascript specs so you can write error-free react and javasctipt code, if you use Visual Studio Code, you can install eslint from the extension tab to activate this function, other editors just google name of the editor + eslint you will find how to enable it for your editor.

How to contribute

I wrote a small guide on how to contribute and the common etiquette to follow.

simple-react-app's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

simple-react-app's Issues

Missing .gitignore

I just installed this globally and ran the setup script:

simple-react-app sra-test
Initializing project..
npm init -- done

Installing deps -- it might take a few minutes..
events.js:163
      throw er; // Unhandled 'error' event
      ^

Error: ENOENT: no such file or directory, open '/Users/jasonb/.config/fnm/lib/node_modules/simple-react-app/.gitignore'

I can confirm I have no .gitignore file in that directory.

New Site / Route

I just wanted to add a new Component to the router and i get a webpack error.
Copied the About.jsx and make a new Test.jsx with same code, added and imported it everywhere.

Child html-webpack-plugin for "index.html":
1 asset
Entrypoint undefined = index.html

What do I wrong?

Remove the required-jsdoc rule from eslint

the file .eslintrc has a custom rule that makes JSDocs mandatory for every function and method, I feel like it's too much, so I'd like to take the rule out, open to help anyone who wants to take the issue.

Rewrite App.jsx as dumb component

At the moment App.jsx main component is written as a class, since it does not use state, it could potentially be rewritten as a simple ES6 functional component.

I'm open to help anyone who wants to take this issue as first one to learn about React.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.