Skip to content

Commit

Permalink
Merge pull request gaearon#639 from gaearon/hot-container
Browse files Browse the repository at this point in the history
Rename AppContainer into HotContainer
  • Loading branch information
gregberge authored Sep 27, 2017
2 parents 2679e73 + 7d1d294 commit 60503a7
Show file tree
Hide file tree
Showing 8 changed files with 74 additions and 74 deletions.
20 changes: 10 additions & 10 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,20 +81,20 @@ Provided by community:
}
```

- `<AppContainer/>` is a component that handles module reloading, as well as error handling. The root component of your app should be nested in AppContainer as a child. When in production, AppContainer is automatically disabled, and simply returns its children.
- `<HotContainer/>` is a component that handles module reloading, as well as error handling. The root component of your app should be nested in HotContainer as a child. When in production, HotContainer is automatically disabled, and simply returns its children.

- React Hot Loader 3 does not hide the hot module replacement API, so the following needs to be added below wherever you call `ReactDOM.render` in your app:

```jsx
import React from 'react'
import ReactDOM from 'react-dom'
import { AppContainer } from 'react-hot-loader'
import { HotContainer } from 'react-hot-loader'
import App from './containers/App'

ReactDOM.render(
<AppContainer>
<HotContainer>
<App/>
</AppContainer>,
</HotContainer>,
document.getElementById('root')
);

Expand All @@ -103,9 +103,9 @@ if (module.hot) {
module.hot.accept('./containers/App', () => {
const NextApp = require('./containers/App').default;
ReactDOM.render(
<AppContainer>
<HotContainer>
<NextApp/>
</AppContainer>,
</HotContainer>,
document.getElementById('root')
);
});
Expand All @@ -123,15 +123,15 @@ Because Webpack 2+ has built-in support for ES2015 modules, you won't need to re
```jsx
import React from 'react'
import ReactDOM from 'react-dom'
import { AppContainer } from 'react-hot-loader'
import { HotContainer } from 'react-hot-loader'

import App from './containers/App'

const render = Component => {
ReactDOM.render(
<AppContainer>
<HotContainer>
<Component />
</AppContainer>,
</HotContainer>,
document.getElementById('root')
)
}
Expand Down Expand Up @@ -183,7 +183,7 @@ Hot reloading code is just one line in the beginning and one line in the end of
}
```

* Add `AppContainer` to `src/index.js` (see `AppContainer` section in [Migration to 3.0 above](https://github.com/gaearon/react-hot-loader/blob/master/docs/README.md#migration-to-30))
* Add `HotContainer` to `src/index.js` (see `HotContainer` section in [Migration to 3.0 above](https://github.com/gaearon/react-hot-loader/blob/master/docs/README.md#migration-to-30))

## TypeScript

Expand Down
4 changes: 2 additions & 2 deletions docs/TipsAndTricks.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ CustomErrorReporter.propTypes = {
};

render((
<AppContainer errorReporter={ CustomErrorReporter }>
<HotContainer errorReporter={ CustomErrorReporter }>
<AppRoot />
</AppContainer>
</HotContainer>
), document.getElementById('react-root'));
```

Expand Down
8 changes: 4 additions & 4 deletions src/AppContainer.dev.js → src/HotContainer.dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const deepForceUpdate = require('react-deep-force-update')

const { Component } = React

class AppContainer extends Component {
class HotContainer extends Component {
constructor(props) {
super(props)
this.state = { error: null }
Expand Down Expand Up @@ -64,11 +64,11 @@ class AppContainer extends Component {
}
}

AppContainer.propTypes = {
HotContainer.propTypes = {
children(props) {
if (React.Children.count(props.children) !== 1) {
return new Error(
'Invalid prop "children" supplied to AppContainer. ' +
'Invalid prop "children" supplied to HotContainer. ' +
'Expected a single React element with your app’s root component, e.g. <App />.',
)
}
Expand All @@ -81,4 +81,4 @@ AppContainer.propTypes = {
]),
}

module.exports = AppContainer
module.exports = HotContainer
4 changes: 2 additions & 2 deletions src/AppContainer.js → src/HotContainer.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* eslint-disable global-require */

if (!module.hot || process.env.NODE_ENV === 'production') {
module.exports = require('./AppContainer.prod')
module.exports = require('./HotContainer.prod')
} else {
module.exports = require('./AppContainer.dev')
module.exports = require('./HotContainer.dev')
}
4 changes: 2 additions & 2 deletions src/AppContainer.prod.js → src/HotContainer.prod.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const React = require('react')

const { Component } = React

class AppContainer extends Component {
class HotContainer extends Component {
render() {
if (this.props.component) {
return <this.props.component {...this.props.props} />
Expand All @@ -14,4 +14,4 @@ class AppContainer extends Component {
}
}

module.exports = AppContainer
module.exports = HotContainer
8 changes: 4 additions & 4 deletions src/index.dev.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const AppContainer = require('./AppContainer')
const HotContainer = require('./HotContainer')

module.exports = function warnAboutIncorrectUsage(arg) {
if (this && this.callback) {
Expand Down Expand Up @@ -27,11 +27,11 @@ module.exports = function warnAboutIncorrectUsage(arg) {
throw new Error(
'React Hot Loader does not have a default export. ' +
'If you use the import statement, make sure to include the ' +
'curly braces: import { AppContainer } from "react-hot-loader". ' +
'curly braces: import { HotContainer } from "react-hot-loader". ' +
'If you use CommonJS, make sure to read the named export: ' +
'require("react-hot-loader").AppContainer.',
'require("react-hot-loader").HotContainer.',
)
}
}

module.exports.AppContainer = AppContainer
module.exports.HotContainer = HotContainer
2 changes: 1 addition & 1 deletion src/index.prod.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
module.exports.AppContainer = require('./AppContainer')
module.exports.HotContainer = require('./HotContainer')
Loading

0 comments on commit 60503a7

Please sign in to comment.