diff --git a/.eslintrc.js b/.eslintrc.js
index 62859ad..fbb977f 100644
--- a/.eslintrc.js
+++ b/.eslintrc.js
@@ -1,3 +1,3 @@
module.exports = {
- extends: 'react-tools'
+ extends: 'react-tools',
}
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 97184ce..10cbb84 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,119 +1,149 @@
## 6.7.5
+
#### Fixes & Optimizations
-- Now passes `column` to `getResizerProps` (#667)
-- NOTE: `getResizerProps` is now only called if the column is resizable
-- Fixes the `className` ordering in defaultProps for ThComponent (#673)
-- NOTE: user supplied classNames now come at the end so they can extend the defaults
+
+* Now passes `column` to `getResizerProps` (#667)
+* NOTE: `getResizerProps` is now only called if the column is resizable
+* Fixes the `className` ordering in defaultProps for ThComponent (#673)
+* NOTE: user supplied classNames now come at the end so they can extend the defaults
## 6.7.4
+
#### Fixes & Optimizations
-- Fix Prop types for columns
+
+* Fix Prop types for columns
## 6.7.3
+
#### Fixes & Optimizations
-- Fix the rest of the proptypes
+
+* Fix the rest of the proptypes
## 6.7.2
+
#### Fixes & Optimizations
-- `getPropTypes` proptype check
+
+* `getPropTypes` proptype check
## 6.7.1
+
#### Fixes & Optimizations
-- `eslint-config` moved to dev deps
+
+* `eslint-config` moved to dev deps
## 6.7.0
+
## 6.7.0-alpha-0
+
#### New Features
-- Expose page/pageSize to rows/cells
-- Supply sort direction to custom sort methods
+
+* Expose page/pageSize to rows/cells
+* Supply sort direction to custom sort methods
#### Fixes & Optimizations
-- README updates
-- Linter cleanup
-- Added PropTypes node module
-- Deps, linting and style upgrades
+
+* README updates
+* Linter cleanup
+* Added PropTypes node module
+* Deps, linting and style upgrades
## 6.6.0
-#### Fixes & Optimizations
-- moved repo to react-tools
-- Doc examples moved to codesandbox.io
-- README updates
-- CSS refacting for rt-tfoot to match rt-thead
-- CSS more specific for input and select
-## 6.5.3
#### Fixes & Optimizations
-- `onClick` proxying and eslint
+
+* moved repo to react-tools
+* Doc examples moved to codesandbox.io
+* README updates
+* CSS refacting for rt-tfoot to match rt-thead
+* CSS more specific for input and select
+
+## 6.5.3
+
+#### Fixes & Optimizations
+
+* `onClick` proxying and eslint
## 6.5.2
+
#### New Features
-- Provide onClick handleOriginal function - #406
+
+* Provide onClick handleOriginal function - #406
#### Fixes & Optimizations
-- README updates
-- `makePathArray` in utils - #326
-- Various fixes: #294, #376, #398, #415,
+
+* README updates
+* `makePathArray` in utils - #326
+* Various fixes: #294, #376, #398, #415,
## 6.5.1
+
#### Fixes & Optimizations
-- `defaultExpanded` now works correctly - #372
-- `column.getProps().rest` props are now applied correctly
-- `makeTemplateComponent` now supports `displayName` - #289
+
+* `defaultExpanded` now works correctly - #372
+* `column.getProps().rest` props are now applied correctly
+* `makeTemplateComponent` now supports `displayName` - #289
## 6.5.0
+
##### New Features
-- `column.filterAll` - defaults to `false`, but when set to `true` will provide the entire array of rows to `filterMethod` as opposed to one row at a time. This allows for more fine-grained filtering using any method you can dream up. See the [Custom Filtering example](https://react-table.js.org/#/story/custom-filtering) for more info.
+
+* `column.filterAll` - defaults to `false`, but when set to `true` will provide the entire array of rows to `filterMethod` as opposed to one row at a time. This allows for more fine-grained filtering using any method you can dream up. See the [Custom Filtering example](https://react-table.js.org/#/story/custom-filtering) for more info.
## 6.4.0
+
##### New Features
-- `PadRowComponent` - the content rendered inside of a padding row. Defaults to a react component that renders ` `
+
+* `PadRowComponent` - the content rendered inside of a padding row. Defaults to a react component that renders ` `
## 6.3.0
+
##### New Features
-- `defaultSortDesc` - allows you to set the default sorting direction for all columns to descending.
-- `column.defaultSortDesc` - allows you to set the default sorting direction for a specific column. Falls back to the global `defaultSortDesc` when not set at all.
+
+* `defaultSortDesc` - allows you to set the default sorting direction for all columns to descending.
+* `column.defaultSortDesc` - allows you to set the default sorting direction for a specific column. Falls back to the global `defaultSortDesc` when not set at all.
## 6.0.0
##### New Features
-- New Renderers:
- - `Aggregated` - Custom renderer for aggregated cells
- - `Pivot` - Custom renderer for Pivoted Cells (utilizes `Expander` and `PivotValue`)
- - `PivotValue` - Custom renderer for Pivot cell values (deprecates the undocumented `pivotRender` option)
- - `Expander` - Custom renderer for Pivot cell Expander
-- Added custom sorting methods per table via `defaultSortMethod` and per column via `column.sortMethod`
-- Pivot columns are now visibly separate and sorted/filtered independently.
-- Added `column.resizable` to override global table `resizable` option for specific columns.
-- Added `column.sortable` to override global table `sortable` option for specific columns.
-- Added `column.filterable` to override global table `filterable` option for specific columns.
-- Added `defaultExpanded` table option.
-- All callbacks can now be utilized without needing to hoist and manage the piece of state they export. That is what their prop counterparts are for, so now the corresponding prop is used instead of the callback to detect a "fully controlled" state.
-- Prevent transitions while column resizing for a smoother resize effect.
-- Disable text selection while resizing columns.
+* New Renderers:
+ * `Aggregated` - Custom renderer for aggregated cells
+ * `Pivot` - Custom renderer for Pivoted Cells (utilizes `Expander` and `PivotValue`)
+ * `PivotValue` - Custom renderer for Pivot cell values (deprecates the undocumented `pivotRender` option)
+ * `Expander` - Custom renderer for Pivot cell Expander
+* Added custom sorting methods per table via `defaultSortMethod` and per column via `column.sortMethod`
+* Pivot columns are now visibly separate and sorted/filtered independently.
+* Added `column.resizable` to override global table `resizable` option for specific columns.
+* Added `column.sortable` to override global table `sortable` option for specific columns.
+* Added `column.filterable` to override global table `filterable` option for specific columns.
+* Added `defaultExpanded` table option.
+* All callbacks can now be utilized without needing to hoist and manage the piece of state they export. That is what their prop counterparts are for, so now the corresponding prop is used instead of the callback to detect a "fully controlled" state.
+* Prevent transitions while column resizing for a smoother resize effect.
+* Disable text selection while resizing columns.
##### Breaking API Changes
-- New Renderers:
- - `Cell` - deprecates and replaces `render`
- - `Header` - deprecates and replaces `header`
- - `Footer` - deprecates and replaces `footer`
- - `Filter`- deprecates and replaces `filterRender`
-- Callbacks now provide the destination state as the primary parameter(s). This makes hoisting and controlling the state in redux or component state much easier. eg.
- - `onSorting` no longer requires you to build your own toggle logic
- - `onResize` no longer requires you to build your own resize logic
-- Renamed `onChange` callback -> `onFetchData` which will always fire when a new data model needs to be fetched (or if not using `manual`, when new data is materialized internally).
-- Renamed `filtering` -> `filtered`
-- Renamed `sorting` -> `sorted`
-- Renamed `expandedRows` -> `expanded`
-- Renamed `resizing` -> `resized`
-- Renamed `defaultResizing` -> `defaultResized`
-- Renamed `defaultFiltering` -> `defaultFiltered`
-- Renamed `defaultSorting` -> `defaultSorted`
-- Renamed `onSortingChange` -> `onSortedChange`
-- Renamed `onFilteringChange` -> `onFilteredChange`
-- Renamed `onResize` -> `onResizedChange`
-- Renamed `onExpandRow` -> `onExpandedChange`
-- Renamed `showFilters` -> `filterable`
-- Renamed `hideFilter` -> `filterable` (Column option. Note the true/false value is now flipped.)
-- `cellInfo.row` and `rowInfo.row` now reference the materialize data for the table. To reference the original row, use `cellInfo.original` and `rowInfo.original`
-- Removed `pivotRender` column option. You can now control how the value is displayed by overriding the `PivotValueComponent` or the individual column's `PivotValue` renderer. See [Pivoting Options Story](https://react-table.js.org/?selectedKind=2.%20Demos&selectedStory=Pivoting%20Options&full=0&down=1&left=1&panelRight=0&downPanel=kadirahq%2Fstorybook-addon-actions%2Factions-panel) for a reference on how to customize pivot column rendering.
+
+* New Renderers:
+ * `Cell` - deprecates and replaces `render`
+ * `Header` - deprecates and replaces `header`
+ * `Footer` - deprecates and replaces `footer`
+ * `Filter`- deprecates and replaces `filterRender`
+* Callbacks now provide the destination state as the primary parameter(s). This makes hoisting and controlling the state in redux or component state much easier. eg.
+ * `onSorting` no longer requires you to build your own toggle logic
+ * `onResize` no longer requires you to build your own resize logic
+* Renamed `onChange` callback -> `onFetchData` which will always fire when a new data model needs to be fetched (or if not using `manual`, when new data is materialized internally).
+* Renamed `filtering` -> `filtered`
+* Renamed `sorting` -> `sorted`
+* Renamed `expandedRows` -> `expanded`
+* Renamed `resizing` -> `resized`
+* Renamed `defaultResizing` -> `defaultResized`
+* Renamed `defaultFiltering` -> `defaultFiltered`
+* Renamed `defaultSorting` -> `defaultSorted`
+* Renamed `onSortingChange` -> `onSortedChange`
+* Renamed `onFilteringChange` -> `onFilteredChange`
+* Renamed `onResize` -> `onResizedChange`
+* Renamed `onExpandRow` -> `onExpandedChange`
+* Renamed `showFilters` -> `filterable`
+* Renamed `hideFilter` -> `filterable` (Column option. Note the true/false value is now flipped.)
+* `cellInfo.row` and `rowInfo.row` now reference the materialize data for the table. To reference the original row, use `cellInfo.original` and `rowInfo.original`
+* Removed `pivotRender` column option. You can now control how the value is displayed by overriding the `PivotValueComponent` or the individual column's `PivotValue` renderer. See [Pivoting Options Story](https://react-table.js.org/?selectedKind=2.%20Demos&selectedStory=Pivoting%20Options&full=0&down=1&left=1&panelRight=0&downPanel=kadirahq%2Fstorybook-addon-actions%2Factions-panel) for a reference on how to customize pivot column rendering.
diff --git a/ISSUE_TEMPLATE.md b/ISSUE_TEMPLATE.md
index bd19e34..1979b80 100644
--- a/ISSUE_TEMPLATE.md
+++ b/ISSUE_TEMPLATE.md
@@ -1,14 +1,18 @@
## What version of React-Table are you using?
+
Your bug may already be fixed in the latest release. Run `yarn upgrade react-table`!
Place your version here...
## What bug are you experiencing, or what feature are you proposing?
+
Please include a detailed explanation here...
## Use https://codesandbox.io/s/X6npLXPRW (by clicking the "Fork" button) to reproduce the issue.
+
Then paste a link to your newly forked codesandbox here...
## What are the steps to reproduce the issue?
-1. list the steps
-2. to reproduce
-3. the issue
+
+1. list the steps
+2. to reproduce
+3. the issue
diff --git a/README.md b/README.md
index a7916b3..56a5cca 100644
--- a/README.md
+++ b/README.md
@@ -3,6 +3,7 @@
# React Table
+
`react-table` is a **lightweight, fast and extendable datagrid** built for React
@@ -28,49 +29,53 @@
## Features
-- Lightweight at 11kb (and just 2kb more for styles)
-- Fully customizable (JSX, templates, state, styles, callbacks)
-- Client-side & Server-side pagination
-- Multi-sort
-- Filters
-- Pivoting & Aggregation
-- Minimal design & easily themeable
-- Fully controllable via optional props and callbacks
-- "Why I wrote React Table and the problems it has solved for Nozzle.io" by Tanner Linsley
+
+* Lightweight at 11kb (and just 2kb more for styles)
+* Fully customizable (JSX, templates, state, styles, callbacks)
+* Client-side & Server-side pagination
+* Multi-sort
+* Filters
+* Pivoting & Aggregation
+* Minimal design & easily themeable
+* Fully controllable via optional props and callbacks
+* "Why I wrote React Table and the problems it has solved for Nozzle.io" by Tanner Linsley
## [Demos and examples](http://react-table.js.org/#/story/simple-table)
## Versions
-- This documentation is for version 6 of react-table.
-- [View the Changelog](https://github.com/react-tools/react-table/blob/master/CHANGELOG.md)
-- Previous versions:
- - [5.x.x Readme](https://github.com/react-tools/react-table/blob/ad7d31cd3978eb45da7c6194dbab93c1e9a8594d/README.md)
+
+* This documentation is for version 6 of react-table.
+* [View the Changelog](https://github.com/react-tools/react-table/blob/master/CHANGELOG.md)
+* Previous versions:
+ * [5.x.x Readme](https://github.com/react-tools/react-table/blob/ad7d31cd3978eb45da7c6194dbab93c1e9a8594d/README.md)
## Table of Contents
-- [Installation](#installation)
-- [Example](#example)
-- [Data](#data)
-- [Props](#props)
-- [Columns](#columns)
-- [Column Header Groups](#column-header-groups)
-- [Custom Cell and Header and Footer Rendering](#custom-cell-header-and-footer-rendering)
-- [Styles](#styles)
-- [Custom Props](#custom-props)
-- [Pivoting and Aggregation](#pivoting-and-aggregation)
-- [Sub Tables and Sub Components](#sub-tables-and-sub-components)
-- [Server-side Data](#server-side-data)
-- [Fully Controlled Component](#fully-controlled-component)
-- [Functional Rendering](#functional-rendering)
-- [Multi-Sort](#multi-sort)
-- [Filtering](#filtering)
-- [Component Overrides](#component-overrides)
-- [Contributing](#contributing)
-- [Scripts](#scripts)
-- [Used By](#used-by)
+* [Installation](#installation)
+* [Example](#example)
+* [Data](#data)
+* [Props](#props)
+* [Columns](#columns)
+* [Column Header Groups](#column-header-groups)
+* [Custom Cell and Header and Footer Rendering](#custom-cell-header-and-footer-rendering)
+* [Styles](#styles)
+* [Custom Props](#custom-props)
+* [Pivoting and Aggregation](#pivoting-and-aggregation)
+* [Sub Tables and Sub Components](#sub-tables-and-sub-components)
+* [Server-side Data](#server-side-data)
+* [Fully Controlled Component](#fully-controlled-component)
+* [Functional Rendering](#functional-rendering)
+* [Multi-Sort](#multi-sort)
+* [Filtering](#filtering)
+* [Component Overrides](#component-overrides)
+* [Contributing](#contributing)
+* [Scripts](#scripts)
+* [Used By](#used-by)
## Installation
-1. Install React Table as a dependency
+
+1. Install React Table as a dependency
+
```bash
# Yarn
$ yarn add react-table
@@ -78,21 +83,27 @@ $ yarn add react-table
# NPM
$ npm install react-table
```
-2. Import the `react-table` module
+
+2. Import the `react-table` module
+
```javascript
// ES6
-import ReactTable from 'react-table'
+import ReactTable from "react-table";
// ES5
-var ReactTable = require('react-table').default
+var ReactTable = require("react-table").default;
```
-3. Import styles by including `react-table.css`
+
+3. Import styles by including `react-table.css`
+
```javascript
// JS (Webpack)
import 'react-table/react-table.css'
// Old-school
```
+
##### CDN
+
```html
@@ -106,8 +117,8 @@ import 'react-table/react-table.css'
```
-
## Example
+
```javascript
import ReactTable from 'react-table'
@@ -147,11 +158,13 @@ render() {
```
## Data
+
Simply pass the `data` prop anything that resembles an array or object. Client-side sorting and pagination are built in, and your table will update gracefully as you change any props. [Server-side data](#server-side-data) is also supported!
-
## Props
+
These are all of the available props (and their default values) for the main `
state.allVisibleColumns === {JSON.stringify(state.allVisibleColumns, null, 4)}
+
+
+ state.allVisibleColumns ==={" "}
+ {JSON.stringify(state.allVisibleColumns, null, 4)}
+
+
{makeTable()}
+>
+> **For Visual Studio Code users**
->**For Visual Studio Code users**
+> VS Code ESLint plugin automatically detects Create React App's configuration file. So you do not need to create `eslintrc.json` at the root directory, except when you want to add your own rules. In that case, you should include CRA's config by adding this line:
->VS Code ESLint plugin automatically detects Create React App's configuration file. So you do not need to create `eslintrc.json` at the root directory, except when you want to add your own rules. In that case, you should include CRA's config by adding this line:
-
->```js
-{
- // ...
- "extends": "react-app"
-}
-```
+> ```js
+> {
+> // ...
+> "extends": "react-app"
+> }
+> ```
+````
Then add this block to the `package.json` file of your project:
```js
@@ -242,9 +242,9 @@ Then add this block to the `package.json` file of your project:
"extends": "react-app"
}
}
-```
+````
-Finally, you will need to install some packages *globally*:
+Finally, you will need to install some packages _globally_:
```sh
npm install -g eslint-config-react-app@0.3.0 eslint@3.8.1 babel-eslint@7.0.0 eslint-plugin-react@6.4.1 eslint-plugin-import@2.0.1 eslint-plugin-jsx-a11y@4.0.0 eslint-plugin-flowtype@2.21.0
@@ -265,17 +265,19 @@ Then add the block below to your `launch.json` file and put it inside the `.vsco
```json
{
"version": "0.2.0",
- "configurations": [{
- "name": "Chrome",
- "type": "chrome",
- "request": "launch",
- "url": "http://localhost:3000",
- "webRoot": "${workspaceRoot}/src",
- "userDataDir": "${workspaceRoot}/.vscode/chrome",
- "sourceMapPathOverrides": {
- "webpack:///src/*": "${webRoot}/*"
+ "configurations": [
+ {
+ "name": "Chrome",
+ "type": "chrome",
+ "request": "launch",
+ "url": "http://localhost:3000",
+ "webRoot": "${workspaceRoot}/src",
+ "userDataDir": "${workspaceRoot}/.vscode/chrome",
+ "sourceMapPathOverrides": {
+ "webpack:///src/*": "${webRoot}/*"
+ }
}
- }]
+ ]
}
```
@@ -309,7 +311,7 @@ For example:
### `Button.js`
```js
-import React, { Component } from 'react';
+import React, { Component } from "react";
class Button extends Component {
render() {
@@ -322,10 +324,9 @@ export default Button; // Don’t forget to use export default!
### `DangerButton.js`
-
```js
-import React, { Component } from 'react';
-import Button from './Button'; // Import a component from another file
+import React, { Component } from "react";
+import Button from "./Button"; // Import a component from another file
class DangerButton extends Component {
render() {
@@ -363,8 +364,8 @@ This project setup uses [Webpack](https://webpack.github.io/) for handling all a
### `Button.js`
```js
-import React, { Component } from 'react';
-import './Button.css'; // Tell Webpack that Button.js uses these styles
+import React, { Component } from "react";
+import "./Button.css"; // Tell Webpack that Button.js uses these styles
class Button extends Component {
render() {
@@ -403,11 +404,11 @@ becomes this:
display: flex;
-webkit-box-orient: horizontal;
-webkit-box-direction: normal;
- -ms-flex-direction: row;
- flex-direction: row;
+ -ms-flex-direction: row;
+ flex-direction: row;
-webkit-box-align: center;
- -ms-flex-align: center;
- align-items: center;
+ -ms-flex-align: center;
+ align-items: center;
}
```
@@ -436,7 +437,7 @@ Then in `package.json`, add the following lines to `scripts`:
"test": "react-scripts test --env=jsdom",
```
->Note: To use a different preprocessor, replace `build-css` and `watch-css` commands according to your preprocessor’s documentation.
+> Note: To use a different preprocessor, replace `build-css` and `watch-css` commands according to your preprocessor’s documentation.
Now you can rename `src/App.css` to `src/App.scss` and run `npm run watch-css`. The watcher will find every Sass file in `src` subdirectories, and create a corresponding CSS file next to it, in our case overwriting `src/App.css`. Since `src/App.js` still imports `src/App.css`, the styles become a part of your application. You can now edit `src/App.scss`, and `src/App.css` will be regenerated.
@@ -477,8 +478,8 @@ You can **`import` an image right in a JavaScript module**. This tells Webpack t
Here is an example:
```js
-import React from 'react';
-import logo from './logo.png'; // Tell Webpack this JS file uses this image
+import React from "react";
+import logo from "./logo.png"; // Tell Webpack this JS file uses this image
console.log(logo); // /logo.84287d09.png
@@ -509,7 +510,7 @@ An alternative way of handling static assets is described in the next section.
## Using the `public` Folder
->Note: this feature is available with `react-scripts@0.5.0` and higher.
+> Note: this feature is available with `react-scripts@0.5.0` and higher.
### Changing the HTML
@@ -530,7 +531,7 @@ This mechanism provides a number of benefits:
However there is an **escape hatch** that you can use to add an asset outside of the module system.
-If you put a file into the `public` folder, it will **not** be processed by Webpack. Instead it will be copied into the build folder untouched. To reference assets in the `public` folder, you need to use a special variable called `PUBLIC_URL`.
+If you put a file into the `public` folder, it will **not** be processed by Webpack. Instead it will be copied into the build folder untouched. To reference assets in the `public` folder, you need to use a special variable called `PUBLIC_URL`.
Inside `index.html`, you can use it like this:
@@ -596,19 +597,19 @@ npm install react-bootstrap --save
npm install bootstrap@3 --save
```
-Import Bootstrap CSS and optionally Bootstrap theme CSS in the beginning of your ```src/index.js``` file:
+Import Bootstrap CSS and optionally Bootstrap theme CSS in the beginning of your `src/index.js` file:
```js
-import 'bootstrap/dist/css/bootstrap.css';
-import 'bootstrap/dist/css/bootstrap-theme.css';
+import "bootstrap/dist/css/bootstrap.css";
+import "bootstrap/dist/css/bootstrap-theme.css";
// Put any other imports below so that CSS from your
// components takes precedence over default styles.
```
-Import required React Bootstrap components within ```src/App.js``` file or your custom component files:
+Import required React Bootstrap components within `src/App.js` file or your custom component files:
```js
-import { Navbar, Jumbotron, Button } from 'react-bootstrap';
+import { Navbar, Jumbotron, Button } from "react-bootstrap";
```
Now you are ready to use the imported React Bootstrap components within your component hierarchy defined in the render method. Here is an example [`App.js`](https://gist.githubusercontent.com/gaearon/85d8c067f6af1e56277c82d19fd4da7b/raw/6158dd991b67284e9fc8d70b9d973efe87659d72/App.js) redone using React Bootstrap.
@@ -632,10 +633,10 @@ Recent versions of [Flow](http://flowtype.org/) work with Create React App proje
To add Flow to a Create React App project, follow these steps:
-1. Run `npm install --save-dev flow-bin` (or `yarn add --dev flow-bin`).
-2. Add `"flow": "flow"` to the `scripts` section of your `package.json`.
-3. Run `npm run flow -- init` (or `yarn flow -- init`) to create a [`.flowconfig` file](https://flowtype.org/docs/advanced-configuration.html) in the root directory.
-4. Add `// @flow` to any files you want to type check (for example, to `src/App.js`).
+1. Run `npm install --save-dev flow-bin` (or `yarn add --dev flow-bin`).
+2. Add `"flow": "flow"` to the `scripts` section of your `package.json`.
+3. Run `npm run flow -- init` (or `yarn flow -- init`) to create a [`.flowconfig` file](https://flowtype.org/docs/advanced-configuration.html) in the root directory.
+4. Add `// @flow` to any files you want to type check (for example, to `src/App.js`).
Now you can run `npm run flow` (or `yarn flow`) to check the files for type errors.
You can optionally use an IDE like [Nuclide](https://nuclide.io/docs/languages/flow/) for a better integrated experience.
@@ -645,7 +646,7 @@ To learn more about Flow, check out [its documentation](https://flowtype.org/).
## Adding Custom Environment Variables
->Note: this feature is available with `react-scripts@0.2.3` and higher.
+> Note: this feature is available with `react-scripts@0.2.3` and higher.
Your project can consume variables declared in your environment as if they were declared locally in your JS files. By
default you will have `NODE_ENV` defined for you, and any other environment variables starting with
@@ -653,7 +654,7 @@ default you will have `NODE_ENV` defined for you, and any other environment vari
**The environment variables are embedded during the build time**. Since Create React App produces a static HTML/CSS/JS bundle, it can’t possibly read them at runtime. To read them at runtime, you would need to load HTML into memory on the server and replace placeholders in runtime, just like [described here](#injecting-data-from-the-server-into-the-page). Alternatively you can rebuild the app on the server anytime you change them.
->Note: You must create custom environment variables beginning with `REACT_APP_`. Any other variables except `NODE_ENV` will be ignored to avoid accidentally [exposing a private key on the machine that could have the same name](https://github.com/facebookincubator/create-react-app/issues/865#issuecomment-252199527). Changing any environment variables will require you to restart the development server if it is running.
+> Note: You must create custom environment variables beginning with `REACT_APP_`. Any other variables except `NODE_ENV` will be ignored to avoid accidentally [exposing a private key on the machine that could have the same name](https://github.com/facebookincubator/create-react-app/issues/865#issuecomment-252199527). Changing any environment variables will require you to restart the development server if it is running.
These environment variables will be defined for you on `process.env`. For example, having an environment
variable named `REACT_APP_SECRET_CODE` will be exposed in your JS as `process.env.REACT_APP_SECRET_CODE`.
@@ -699,7 +700,7 @@ a `.env` file. Both of these ways are described in the next few sections.
Having access to the `NODE_ENV` is also useful for performing actions conditionally:
```js
-if (process.env.NODE_ENV !== 'production') {
+if (process.env.NODE_ENV !== "production") {
analytics.disable();
}
```
@@ -708,7 +709,7 @@ When you compile the app with `npm run build`, the minification step will strip
### Referencing Environment Variables in the HTML
->Note: this feature is available with `react-scripts@0.9.0` and higher.
+> Note: this feature is available with `react-scripts@0.9.0` and higher.
You can also access the environment variables starting with `REACT_APP_` in the `public/index.html`. For example:
@@ -742,7 +743,7 @@ REACT_APP_SECRET_CODE=abcdef npm start
### Adding Development Environment Variables In `.env`
->Note: this feature is available with `react-scripts@0.5.0` and higher.
+> Note: this feature is available with `react-scripts@0.5.0` and higher.
To define permanent environment variables, create a file called `.env` in the root of your project:
@@ -753,8 +754,8 @@ REACT_APP_SECRET_CODE=abcdef
These variables will act as the defaults if the machine does not explicitly set them.
- This example combines two HOCs (the TreeTable and the SelectTable) to make a composite component.
++ This example combines two HOCs (the TreeTable and the SelectTable) to + make a composite component. +
We'll call it SelectTreeTable!
Here is what the buttons do:
- NOTE: the selection is maintained when toggling the tree on and off but is cleared - when switching between select types (radio, checkbox). + NOTE: the selection is maintained when toggling the + tree on and off but is cleared when switching between select types + (radio, checkbox).
- - + + {` (${this.state.selection.length}) selected`} - { - data? + {data ? (