Examples illustrating key concepts in ReactJS. Includes minimal Webpack 4 configuration where required.
For JSX, component, properties, state, stateless functional components, inches to centimetres calculator, router DOM, form field validation and form validation on submit examples.
- Install dependencies:
npm install
- Compile and watch:
npm run compile-watch
Router DOM example depends on a server side environment.
Rendering an element.
Combining JSX to render elements.
Component based architecture.
Utilising props to render content.
Assinging state to a class.
Assinging state to a class that converts inches to centimetres.
Presentational and container components.
Modular Sass, where class names are scoped locally by default.
Uses React Router v4 to render components on the server. This needs a server like localhost for routes to work.
Returns warnings and disables submit button if form field are left empty.
Returns warnings if field are left empty or email is invalid after submitted.
For server router, data, meta, router fade in fade out, contact form SMTP, CRUD, CRUD redux and OAuth Redux examples.
- Install dependencies:
npm install
- Compile client:
npm run compile
- Compile server:
npm run compile-server
- Start server:
node server.js
- Visit: http://localhost:3000
Uses React Router v4 for universal routes to render components on the server.
Components to render JSON data, includes universal routing with React Router v4 and pagination.
Uses React Helmet to render meta titles and descriptions.
Uses React Router v4 and React Transition Group v2 to fade routes in and out.
Uses Nodemailer to send email over SMTP. Requires a configuration file with your email credentials; IP address, port, user email and password.
config/keys.js
const keys = {
mtHost: '1.1.1.1',
mtPort: 111,
mtUser: 'you@example.com',
mtPass: 'password'
}
export default keys
Requires a MongoDB installation. Listening on default port: 27017.
Create, read, update and delete, uses MongoDB to store data.
Data is not persisted in this example, therefore to update state from the database a browser refresh is required. This example is intended as a stepping stone for the following CRUD Redux example.
Requires a MongoDB installation. Listening on default port: 27017.
Create, read, update and delete, uses MongoDB to store data and Redux to persist state.
Authorised routes, user login using Passport and Google OAuth 2.0, uses Redux to persist state.
For server code splitting example.
- Install dependencies:
npm install
- Compile client:
npm run dev
- Visit: http://localhost:3000
Uses React Loadable to split and load code.
Licensed under the MIT License.