Code Monkey home page Code Monkey logo

react-lego's Introduction

React Lego CircleCI

The building blocks of a react app

This repo demonstrates how to plug in other technologies, one block at a time, into React.

Hear me out!

The concept is to use GitHub's branch-comparison screens to quickly demo the code changes that are needed for only the technology you are interested in.

The default branch (universal) is a Universal React App, each other branch then adds one more technology, with the smallest possible changes. This master branch, and therefore all branches, have been setup with continuous deployment.

>> More about the concept

Branches available to compare:

All branches are written using es6 and babel with webpack.

React Client-side App

The aim of the master branch was to be as close to production ready as possible (minus universal rendering).

These have been chosen as base technologies because (Apart from them being relatively easy to distinguish between), they are essential when building/deploying to make sure I don't break anything!

Preact client-side app

Changed from the master branch. compare branches

Because of Ben Fletcher and this tweet I thought i'd give Preact a shot.

Turns out it was actually very easy! After removing a few dependencies we swapped routers for preact-router.

Universal React App

Based on the master branch. compare branches

The Universal branch is production ready and All other branches are also production ready.

Hot-Reloading

Based on the universal branch. compare branches

react-hot-loader allows you to see changes made to any part of your app without having to restart the server. We are currently using v3.

>> More about adding react-hot-loader

Redux

Based on the universal branch. compare branches

Redux was added with data being hydrated on the server.

The app now has an API which can be called to return the required data. This data is now formatted inside a reducer.

>> More about adding Redux

Redux with Promise middleware

Based on the redux branch. compare branches

This branch allows you to make async requests on the server and hydrate your redux store before rendering the page. The massive win here is that each container dictates what data it needs while still on the server.

>> More about adding Promise middleware

Redux Dev Tools

Based on the redux branch. compare branches

Add Redux-DevTools to the app to help debugging.

>> More about adding redux-dev-tools

Importing SVGs

Based on the universal branch. compare branches

Using webpack-isomorphic-tools and svg-inline-loader we are able to directly import SVGs into our JavaScript. This has the added benefit of :

  • Reusing SVG files (without code duplication)
  • Keep SVGs inline and style them with CSS
  • Serverside rendering of SVG's

>> More about importing SVGs

Using Webpack v2

Based on the universal branch compare branches

This was added out of pure interest and I haven't used it in anger yet. Please take a look at the comparison branch to see how to upgrade from webpack v1 to v2.

>> More about Webpack v2

Using Webpack v2 with React-Hot-loader v3

Based on the webpack2 branch. compare branches

Just added as a quick demo to help out and show the 2 working together. no changes required to either branch to get them to work together.

Using React-Router v4

Based on the universal branch compare branches

React Router v4 sees to be very close to being released so I was interested in how hard the upgrade would be. Easy, it seems - the new syntax includes a lot for JSX which is friendly and more flexible.

>> More about React-Router v4

CSS

In master, we have simply added the CSS into webpack entry array to get it to convert Scss into CSS. these are some other ways to achieve more modular components:

>> More about the different CSS methods

CSS Imports

Based on the universal branch compare branches

Import your css into your component and use the class names as they are written.
This method is the least obtrusive and feels most like traditional css. You must manually take care of css scope using things like BEM or Smaccs.

CSS Modules

Based on the universal branch compare branches

Import your css into your components and add the class names using js object notation. This method completely changes the css class names output. Scoping problems are gone, but you must specifically mark 'global' classes.

CSS in JS

Based on the universal branch compare branches

import your css into your components as Javascript Objects.
Class names are a thing of the past as are scoping problems.

react-lego's People

Contributors

peter-mouland avatar danielwalczak avatar

Watchers

James Cloos avatar  avatar

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.