Coder Social home page Coder Social logo

react_render_build_time's Introduction

The site is rendered at build time, then 'rehydrated' when the javascript bundle loads on the client machine.

Build process:

  1. React app is rendered to a string at build time, passing env=node as a prop. This string is passed into a mustache template.

  2. SCSS and js are compiled, concatenated and minified.

What happens when the page is loaded?

  1. First, a static version of the site is delivered in plain HTML which is seen by the user until 'bundle.js' loads. The state used for the App is DEFAULT_STATE.

  2. When 'bundle.js' has been loaded, parsed and executed, the React app is rendered again. If there are no changes to be made then the DOM is not touched (except for the attachment of event listeners). In our case, since the static version does not contain any of the 'item cards', these will be rendered but the heading etc will not be.

  3. Initially, the app is rendered using DEFAULT_STATE (the same state used on the server). Then, once the App component has mounted, the state is updated (inside componentDidMount()) with the client side state.

    We use DEFAULT_STATE initially so that the render tree can be updated efficiently via setState. If the client state was used straight away, the whole tree would have to be discarded and re-rendered.

react_render_build_time's People

Contributors

christianscott avatar

Watchers

 avatar  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.