npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

construct-react

v1.0.3

Published

Construct React is a boilerplate for web development built on top of Express and React, containing modern web development tools such as [Webpack](https://webpack.js.org/) and [Babel](https://babeljs.io/). It will be the good starting point for professiona

Downloads

66

Readme

Construct React

Construct React is a boilerplate for web development built on top of Express and React, containing modern web development tools such as Webpack and Babel. It will be the good starting point for professionals. You don't need this kit if you don't want SSR, code-splitting and other SEO stuffs.

Main Features!

  • Provides Server Side Rendering (SSR). Web application is being served by Express server
  • Configures React router which provides the Routing functionality.
  • Configures Code Splitting using @loadable/component.
  • Configures Material UI which provides React Components that implement Google's Material design.
  • Configures styled-components. It allows you to write actual CSS code to style your components.
  • Configures React-redux. It lets your React components read data from a Redux store, and dispatch actions to the store to update data.
  • Configures Redux-saga. It is a redux middleware library, that is designed to make handling side effects in your redux app nice and simple.
  • Configures redux-saga-test-plan for testing sagas.
  • Configures axios. It is Promise based HTTP client for the browser and node.js.
  • Configures Enzyme. It is a JavaScript Testing utility for React that makes it easier to assert, manipulate, and traverse your React Components' output.
  • Configures React-Helmet.
  • Configures nodemon. It is a utility for auto restarting the express server.
  • Configures webpack-dev-middleware and webpack-hot-middleware.
  • Configures airbnb for linting.
  • Configures Snapshot testing.

Installation

Install the construct-react library

 npm install -g construct-react
            (or)
 yarn global add construct-react

Create a new project with construct-react

 construct-react app-name
 cd app-name

Install the dependencies and devDependencies.

 yarn install

To start the development server

 yarn dev

To start the production server

 yarn prod

By default, it will start the app in the port 3000. If you want to change the port, edit the value in the port.js file.

To build the application in development environment

 yarn build:dev

To build the application in production environment

 yarn build:prod

To run the lint

 yarn lint

To update the components for snapshot testing

 yarn update-snapshot <file-name>

Set up

React - Helmet

If you want to set up your react-helmet, just create helmet files under /app/helmets and use them in you components. The server side setup are already in place.

Error Boundary

Error boundary file is configured. If you want to change the error content, you can change the /app/ErrorBoundary.jsx.

Load date

If you want to load your data during the server side rendering itself, then you can dispatch the actions in componentWillMount lifecycle method of a component.

For Example,

componentWillMount() {
    const { getAllPosts } = this.props;
    getAllPosts();
  }

you can find this example in /app/components/Posts.jsx. If you trigger an action, then saga will take care of calling API and storing data into the redux store. Below saga configuration has been set up to defer the server side rendering till data are loaded.

store.runSaga(sagas).done.then(() => {
   // send the response
  });

you can find this code in the file /server/Renderer.jsx

Note: If you dispatch an action in componentDidMount, data will be loaded only at client side. componentWillMount will be executed at both server and client sides while componentDidMount will be executed only at client side.

Happy hacking!