React-hot-loader: [3.0] Rename AppContainer to HotContainer

Created on 20 Jul 2016  路  19Comments  路  Source: gaearon/react-hot-loader

AppContainer name is too generic, and It's very common to people use this name for their root containers.

enhancement

Most helpful comment

Why react-router has <Router>? It must be <AppContainer>. Don't you guys think like me?
And we can do this then:

import AppContainer as Router from 'react-router'
import AppContainer as HotContainer 'react-hot-loader'
import AppContainer as Provider from 'redux'
import AppContainer as ...

It's Great!

All 19 comments

rhlContainer is too ugly

You could rename it on import?

import { AppContainer as HotContainer } from ?

I know the import X as Y from Z, I'm using it, but when you start doing this your code starts looking different from everyone else, it becomes "unfamiliar".

I think it's ok to use when you have 2 external modules that by chance got the same name, but let's say that every library that uses React context name their root component "AppContainer" or "Provider", so eveyone is forced to rename it to something. Imagine yorself reading someone else's code, having to do a mental map of all the aliases while reading. I'm just trying to avoid this.

Why react-router has <Router>? It must be <AppContainer>. Don't you guys think like me?
And we can do this then:

import AppContainer as Router from 'react-router'
import AppContainer as HotContainer 'react-hot-loader'
import AppContainer as Provider from 'redux'
import AppContainer as ...

It's Great!

(I am just guessing but) I believe it is AppContainer by analogy with React Native.

HMRContainer or HMRWrapper would be better

@kevinlaw91 HMR is the name of Webpack engine that, replaces modules on the fly (duh). React Hot Loader is the end that connects to Webpack engine to allow React to re-render automatically. So, I'd say RHLContainer or just HotLoader.

@romulof Yeah you're right. Naming should be more general instead. We can consider keywords like "Root" or "Swap" too.

Any module can export any number of identifiers and call them what they want. They are "namespaced" to that module. It's not a global AppContainer that RHL is exporting. It's react-hot-loader's AppContainer.

As such, you're free to rename it as you import it. Any of the following will work:

import { AppContainer as HotContainer } from "react-hot-loader";

<HotContainer>
  <App />
</HotContainer>

Or this:

import * as reactHotLoader from "react-hot-loader";

<reactHotLoader.AppContainer>
  <App />
</reactHotLoader.AppContainer>

If you don't use import/export then:

var HotContainer = require("react-hot-loader").AppContainer;

<HotContainer>
  <App />
</HotContainer>

Read my msg above ^ @harmony7.

I agree. Each library can export a symbol called AppContainer and then we'd differentiate them by the namespace they are from. I'd have no problems with that.

However these are not all written by the same people.

I was joking, @harmony7. It's a terrible Idea. so then if somebody wants to read someone else code he can't understand what is ReloadContainer (!!), because everybody names the Containers whatever he likes! he should scroll to where it is imported to find what is this component.
You name it HotContainer, others ReloadContainer and somebody RHLConrainer, It's not good for a readable source code.

I realize you were joking.

However I don't think the situation is as bad as you make it sound.

Everyone has a different idea about this situation, I just said my opinion. Maybe it is others' opinion about the situation, maybe not.

I agree, HotContainer is more specific.

Agreed

+1

Yes, I love the name HotContainer much more.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Anahkiasen picture Anahkiasen  路  5Comments

mattkrick picture mattkrick  路  3Comments

niba picture niba  路  4Comments

mqklin picture mqklin  路  3Comments

rockchalkwushock picture rockchalkwushock  路  3Comments