File tree Expand file tree Collapse file tree 3 files changed +9
-14
lines changed
Expand file tree Collapse file tree 3 files changed +9
-14
lines changed Original file line number Diff line number Diff line change 11import React , { Component , PropTypes } from 'react' ;
22import Toolbar from 'components/Toolbar' ;
3- import Helmet from 'react-helmet' ;
43import './style.scss' ;
54
6- export default class App extends Component {
7- constructor ( props ) {
8- super ( props ) ;
9- this . state = {
10- preload : [ ]
11- } ;
12- }
5+ const tag = document . createElement ( 'script' ) ;
6+ tag . async = 1 ;
137
8+ const addScript = src => {
9+ tag . src = src ;
10+ document . head . appendChild ( tag . cloneNode ( ) ) ;
11+ } ;
12+
13+ export default class App extends Component {
1414 componentDidMount ( ) {
15- this . setState ( {
16- preload : window . __CHUNKS . map ( chunk => ( { href : chunk , rel : 'preload' , as : 'script' } ) )
17- } ) ;
15+ window . __CHUNKS . forEach ( addScript ) ;
1816 }
1917
2018 render ( ) {
2119 return (
2220 < main className = "viewport" >
23- < Helmet link = { this . state . preload } />
2421 < Toolbar />
2522 { this . props . children }
2623 </ main >
Original file line number Diff line number Diff line change 3232 "babel-runtime" : " ^6.16.0" ,
3333 "react" : " ^15.3.0" ,
3434 "react-dom" : " ^15.3.0" ,
35- "react-helmet" : " ^3.2.2" ,
3635 "react-router" : " ^2.8.0"
3736 }
3837}
Original file line number Diff line number Diff line change @@ -110,7 +110,6 @@ module.exports = {
110110 vendor : [
111111 'react' ,
112112 'react-dom' ,
113- 'react-helmet'
114113 ]
115114 } ,
116115 output : {
You can’t perform that action at this time.
0 commit comments