-
Notifications
You must be signed in to change notification settings - Fork 45
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cannot read property 'insertBefore' of null #64
Comments
how are you using createNewHosts |
Apologies for the delay was not at my computer all weekend. declare const ENV:any;
import './polyfills';
import './rxjs.imports';
import { enableProdMode } from '@angular/core';
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { bootloader } from '@angularclass/hmr';
import {decorateModuleRef} from "./env";
import {AppModule} from "./app/app.module";
if (ENV === 'production'){
enableProdMode();
}
export function main():Promise<any> {
return platformBrowserDynamic()
.bootstrapModule(AppModule)
.then(decorateModuleRef)
.catch(err => console.log(err))
}
bootloader(main); App.module.ts import {NgModule, ApplicationRef} from '@angular/core';
import {BrowserModule} from '@angular/platform-browser'
import { removeNgStyles, createNewHosts, createInputTransfer } from '@angularclass/hmr';
import { Store , StoreModule} from '@ngrx/store';
import {AppComponent} from './app.comp';
import {rootReducer} from './reducers';
import {counterReducer} from "./counter/counter.reducer";
import {CounterComponent} from "./counter/counter.component";
@NgModule({
declarations: [AppComponent, CounterComponent],
imports:[
BrowserModule,
StoreModule.provideStore(rootReducer)
],
bootstrap:[AppComponent],
exports:[]
})
export class AppModule {
constructor(public appRef: ApplicationRef,
private _store: Store<AppState>) {
}
hmrOnInit(store) {
if (!store || !store.rootState) return;
// restore state by dispatch a SET_ROOT_STATE action
if (store.rootState) {
this._store.dispatch({
type: 'SET_ROOT_STATE',
payload: store.rootState
});
}
if ('restoreInputValues' in store) { store.restoreInputValues(); }
this.appRef.tick();
Object.keys(store).forEach(prop => delete store[prop]);
}
hmrOnDestroy(store) {
const cmpLocation = this.appRef.components.map(cmp => cmp.location.nativeElement);
this._store.take(1).subscribe(s => store.rootState = s);
store.disposeOldHosts = createNewHosts(cmpLocation);
store.restoreInputValues = createInputTransfer();
removeNgStyles();
}
hmrAfterDestroy(store) {
store.disposeOldHosts();
delete store.disposeOldHosts;
}
};
export interface AppState {} |
I got same problem. Any update for this issue ? |
Same here. HMR.ts
Main.ts
app.module.ts
|
The problem seems to be here in Helpers.js var parentNode = componentNode.parentNode; <<< componentNode is "app-component" selector, parentNode is "NULL".. however.. parent node in DOM is maybe it is because of angular 6 ? |
Looks like this is occurring in the createNewHosts function call.
The text was updated successfully, but these errors were encountered: