Top Related Projects
Set up a modern web app by running one command.
A JS library for predictable global state management
Declarative routing for React
Storybook is the industry standard workshop for building, documenting, and testing UI components in isolation
š„ A highly scalable, offline-first foundation with the best developer experience and a focus on performance and best practices.
A collection of awesome things regarding React ecosystem
Quick Overview
Essential React is a minimal boilerplate for React applications. It provides a basic setup for building React projects with modern tooling, including Webpack, Babel, and Jest for testing. The project aims to offer a lightweight starting point for developers to quickly begin working on React applications without unnecessary complexity.
Pros
- Minimalistic approach, reducing initial setup time and complexity
- Includes essential tools like Webpack, Babel, and Jest out of the box
- Provides a solid foundation for both small and large-scale React projects
- Regularly updated to keep up with the latest React and tooling versions
Cons
- May lack some advanced features or configurations that larger boilerplates offer
- Requires additional setup for more complex project requirements
- Limited documentation compared to more comprehensive boilerplates
- May not be suitable for developers who prefer a more opinionated project structure
Code Examples
- Basic React component:
import React from 'react';
const HelloWorld = () => {
return <h1>Hello, World!</h1>;
};
export default HelloWorld;
- Using React hooks:
import React, { useState } from 'react';
const Counter = () => {
const [count, setCount] = useState(0);
return (
<div>
<p>Count: {count}</p>
<button onClick={() => setCount(count + 1)}>Increment</button>
</div>
);
};
export default Counter;
- Simple test using Jest:
import React from 'react';
import { render, screen } from '@testing-library/react';
import HelloWorld from './HelloWorld';
test('renders hello world', () => {
render(<HelloWorld />);
const headingElement = screen.getByText(/hello, world/i);
expect(headingElement).toBeInTheDocument();
});
Getting Started
To get started with Essential React, follow these steps:
-
Clone the repository:
git clone https://github.com/pheuter/essential-react.git cd essential-react
-
Install dependencies:
npm install
-
Start the development server:
npm start
-
Open your browser and navigate to
http://localhost:8080
to see your React application running.
Competitor Comparisons
Set up a modern web app by running one command.
Pros of Create React App
- Officially maintained by Facebook, ensuring regular updates and compatibility
- Extensive ecosystem with a wide range of supported tools and libraries
- Simplified setup process with zero configuration required
Cons of Create React App
- Less flexibility for customizing the build process without ejecting
- Larger bundle size due to inclusion of many features by default
- Steeper learning curve for understanding the underlying configuration
Code Comparison
Essential React:
import React from 'react';
import ReactDOM from 'react-dom';
import App from './components/App';
ReactDOM.render(<App />, document.getElementById('root'));
Create React App:
import React from 'react';
import ReactDOM from 'react-dom';
import './index.css';
import App from './App';
import reportWebVitals from './reportWebVitals';
ReactDOM.render(
<React.StrictMode>
<App />
</React.StrictMode>,
document.getElementById('root')
);
reportWebVitals();
The main differences in the code snippets are:
- Create React App includes additional imports for CSS and performance monitoring
- Create React App wraps the App component in React.StrictMode for better development experience
- Create React App calls reportWebVitals() for performance measurement
Both projects aim to simplify React development, but Create React App offers a more comprehensive and officially supported solution, while Essential React provides a lighter, more customizable starting point.
A JS library for predictable global state management
Pros of Redux
- Widely adopted and maintained state management library with extensive ecosystem
- Provides predictable state updates through pure reducer functions
- Excellent developer tools for debugging and time-travel debugging
Cons of Redux
- Steeper learning curve due to additional concepts and boilerplate
- Can be overkill for smaller applications with simple state management needs
- Requires more setup and configuration compared to simpler alternatives
Code Comparison
Essential React:
import React, { useState } from 'react';
function Counter() {
const [count, setCount] = useState(0);
return <button onClick={() => setCount(count + 1)}>{count}</button>;
}
Redux:
import { createStore } from 'redux';
const counterReducer = (state = 0, action) => {
switch (action.type) {
case 'INCREMENT':
return state + 1;
default:
return state;
}
};
const store = createStore(counterReducer);
Essential React focuses on a minimal setup for React applications, providing a straightforward boilerplate with essential tools and configurations. It's ideal for quickly starting new React projects without much overhead.
Redux, on the other hand, is a robust state management library that offers a more structured approach to handling complex application states. It's particularly useful for larger applications with intricate data flows and state updates.
Declarative routing for React
Pros of React Router
- More comprehensive routing solution with advanced features like nested routes and dynamic routing
- Actively maintained with regular updates and a large community
- Extensive documentation and widespread adoption in the React ecosystem
Cons of React Router
- Steeper learning curve for beginners compared to simpler routing solutions
- May introduce unnecessary complexity for small projects with basic routing needs
- Requires additional setup and configuration
Code Comparison
Essential React routing example:
<Route path="/" component={Home} />
<Route path="/about" component={About} />
<Route path="/contact" component={Contact} />
React Router routing example:
<Routes>
<Route path="/" element={<Home />} />
<Route path="about" element={<About />} />
<Route path="contact" element={<Contact />} />
</Routes>
Summary
React Router offers a more robust and feature-rich routing solution compared to Essential React. It provides advanced routing capabilities and is widely adopted in the React community. However, it may be overkill for simple projects and requires more setup. Essential React, on the other hand, offers a simpler approach to routing but lacks the advanced features and active maintenance of React Router. The choice between the two depends on the project's complexity and routing requirements.
Storybook is the industry standard workshop for building, documenting, and testing UI components in isolation
Pros of Storybook
- Extensive ecosystem with addons and integrations
- Supports multiple frameworks (React, Vue, Angular, etc.)
- Active development and large community support
Cons of Storybook
- Steeper learning curve and more complex setup
- Potentially heavier resource usage for larger projects
Code Comparison
Essential React:
import React from 'react';
import ReactDOM from 'react-dom';
import App from './components/App';
ReactDOM.render(<App />, document.getElementById('root'));
Storybook:
import React from 'react';
import { storiesOf } from '@storybook/react';
import { Button } from './Button';
storiesOf('Button', module)
.add('with text', () => <Button>Hello Button</Button>);
Summary
Storybook offers a more comprehensive solution for component development and documentation, supporting multiple frameworks and providing a rich ecosystem of addons. However, it may require more setup and resources compared to Essential React's simpler approach. Essential React focuses on providing a minimal boilerplate for React projects, while Storybook excels in creating isolated component environments for testing and showcase purposes.
š„ A highly scalable, offline-first foundation with the best developer experience and a focus on performance and best practices.
Pros of react-boilerplate
- More comprehensive and feature-rich, offering a complete development environment
- Includes advanced features like code splitting, offline-first functionality, and i18n support
- Actively maintained with frequent updates and a large community
Cons of react-boilerplate
- Steeper learning curve due to its complexity and extensive feature set
- Potentially overkill for smaller projects or beginners
- Requires more setup and configuration time
Code Comparison
essential-react:
import React from 'react';
import ReactDOM from 'react-dom';
import App from './components/App';
ReactDOM.render(<App />, document.getElementById('root'));
react-boilerplate:
import React from 'react';
import ReactDOM from 'react-dom';
import { Provider } from 'react-redux';
import { ConnectedRouter } from 'connected-react-router';
import history from 'utils/history';
import 'sanitize.css/sanitize.css';
import App from 'containers/App';
import configureStore from './configureStore';
const initialState = {};
const store = configureStore(initialState, history);
const MOUNT_NODE = document.getElementById('app');
ReactDOM.render(
<Provider store={store}>
<ConnectedRouter history={history}>
<App />
</ConnectedRouter>
</Provider>,
MOUNT_NODE
);
The code comparison shows that react-boilerplate includes additional setup for Redux, connected-react-router, and other features, while essential-react provides a simpler entry point.
A collection of awesome things regarding React ecosystem
Pros of awesome-react
- Comprehensive collection of React resources, tutorials, and tools
- Regularly updated with new content and community contributions
- Covers a wide range of React-related topics, including libraries, frameworks, and best practices
Cons of awesome-react
- May be overwhelming for beginners due to the sheer amount of information
- Lacks a structured learning path or step-by-step guide
- Does not provide a ready-to-use boilerplate or project structure
Code comparison
Not applicable, as awesome-react is a curated list of resources and does not contain code samples. Essential-react, on the other hand, provides a boilerplate project structure. Here's an example of the project structure in essential-react:
essential-react/
āāā app/
ā āāā components/
ā āāā pages/
ā āāā app.js
āāā build/
āāā config/
āāā package.json
Summary
awesome-react serves as an extensive resource hub for React developers, offering a vast collection of links and references. Essential-react, in contrast, provides a minimal boilerplate for starting React projects. While awesome-react excels in breadth of information, essential-react offers a more hands-on, practical approach for beginners looking to jumpstart their React development.
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
Essential React
A minimal skeleton for building testable React apps using Babel.
Design Goals
- Use fewer tools (no yeoman, gulp, bower, etc...)
- Babel 6 with Webpack and Hot Loader
- Fast testing with mocked-out DOM
- Import css files as class names
- Separate Smart and Dumb components
- No specific implementation of Flux or data fetching patterns
Getting Started
$ npm install
Start the local dev server:
$ npm run server
Navigate to http://localhost:8080/ to view the app.
Commands
A core philosophy of this skeleton app is to keep the tooling to a minimum. For this reason, you can find all the commands in the scripts
section of package.json.
server
$ npm run server
Input: src/main.jsx
This leverages React Hot Loader to automatically start a local dev server and refresh file changes on the fly without reloading the page.
It also automatically includes source maps, allowing you to browse code and set breakpoints on the original ES6 code:
build
$ npm run build
Input: src/main.jsx
Output: build/app.js
Build minified app for production using the production shortcut.
test
$ npm test
Input: test/main.js
Output: coverage/
Leverages ava to execute the test suite and generate code coverage reports using nyc
coveralls
$ npm run coveralls
Input: coverage/lcov.info
Sends the code coverage report generated by nyc to Coveralls.
clean
$ npm run clean
Input: build/app.js
Removes the compiled app file from build.
Changelog
Top Related Projects
Set up a modern web app by running one command.
A JS library for predictable global state management
Declarative routing for React
Storybook is the industry standard workshop for building, documenting, and testing UI components in isolation
š„ A highly scalable, offline-first foundation with the best developer experience and a focus on performance and best practices.
A collection of awesome things regarding React ecosystem
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot