Created
March 14, 2017 00:33
-
-
Save MegaBlackLabel/604422955ddcd5124897a0c8a7959d29 to your computer and use it in GitHub Desktop.
ESDocが効かないパターン
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
import ReactDOM from 'react-dom'; | |
import injectTapEventPlugin from 'react-tap-event-plugin'; | |
import MuiThemeProvider from 'material-ui/styles/MuiThemeProvider'; | |
import Main from './Main'; | |
injectTapEventPlugin(); | |
// ここでMainをMuiThemeProviderでラップする | |
const App = React.createElement(Main, {}); | |
const StyledApp = React.createElement(MuiThemeProvider, {}, App); | |
ReactDOM.render( | |
StyledApp, | |
document.getElementById('root'), | |
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// main.jsx | |
import React, { Component } from 'react'; | |
/** | |
* メインクラス | |
* | |
* @todo あとでやる | |
*/ | |
class App extends Component { | |
constructor(props, context, updater) { | |
super(props, context, updater); | |
this.state = {}; | |
} | |
render() { | |
return ( | |
... | |
); | |
} | |
} | |
// AppをexportしているのでESDocでAppの記載が出力される | |
export default App; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// index.js | |
import React from 'react'; | |
import ReactDOM from 'react-dom'; | |
import injectTapEventPlugin from 'react-tap-event-plugin'; | |
import Main from './Main'; | |
injectTapEventPlugin(); | |
// ESLintの縛りでjsファイルにJSX形式がかけないためこのように記載 | |
ReactDOM.render( | |
React.createElement(Main, {}), | |
document.getElementById('root'), | |
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// main.jsx | |
import React, { Component } from 'react'; | |
import MuiThemeProvider from 'material-ui/styles/MuiThemeProvider'; | |
/** | |
* メインクラス | |
* | |
* @todo あとでやる | |
*/ | |
class App extends Component { | |
constructor(props, context, updater) { | |
super(props, context, updater); | |
this.state = {}; | |
} | |
render() { | |
return ( | |
... | |
); | |
} | |
} | |
// Material-uiを使用しているのでMuiThemeProviderでラップする必要がある。そのため、exportでラップしていた | |
// 当然ながらexportしているのはStyledAppなので、ESDocではStyledAppが出力される | |
// 本来ならrender内か呼び出されるindex.jsで書くべき処理だった | |
const StyledApp = () => ( | |
<MuiThemeProvider> | |
<App /> | |
</MuiThemeProvider> | |
); | |
export default StyledApp; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment