From 65c4e1e5bd99c44befa94ab1d66fbada3e8986a1 Mon Sep 17 00:00:00 2001 From: Arunoda Susiripala Date: Fri, 2 Dec 2016 19:29:10 +0530 Subject: [PATCH] Init next.js even after dom is loaded. (#326) Earlier we add a event to init next.js when dom has loaded. But if at that time dom is already loaded, next.js won't get init ever. Now we are using domready NPM module which handle these for us. --- client/next.js | 3 ++- examples/shared-modules/package.json | 2 +- package.json | 1 + 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/client/next.js b/client/next.js index 00333dd1..d99830c5 100644 --- a/client/next.js +++ b/client/next.js @@ -1,6 +1,7 @@ import { createElement } from 'react' import { render } from 'react-dom' import HeadManager from './head-manager' +import domready from 'domready' import { rehydrate } from '../lib/css' import Router from '../lib/router' import App from '../lib/app' @@ -10,7 +11,7 @@ const { __NEXT_DATA__: { component, errorComponent, props, ids, err } } = window -document.addEventListener('DOMContentLoaded', () => { +domready(() => { const Component = evalScript(component).default const ErrorComponent = evalScript(errorComponent).default diff --git a/examples/shared-modules/package.json b/examples/shared-modules/package.json index aeb6e6b5..a97acae5 100644 --- a/examples/shared-modules/package.json +++ b/examples/shared-modules/package.json @@ -14,6 +14,6 @@ "author": "", "license": "ISC", "next": { - "cdn": false + "cdn": true } } diff --git a/package.json b/package.json index ad740368..c696f5c2 100644 --- a/package.json +++ b/package.json @@ -66,6 +66,7 @@ "babel-runtime": "6.18.0", "cross-spawn": "5.0.1", "del": "2.2.2", + "domready": "1.0.8", "friendly-errors-webpack-plugin": "1.1.1", "glamor": "2.20.8", "glob-promise": "2.0.0",