-
Notifications
You must be signed in to change notification settings - Fork 13.5k
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
bug: angular, cannot read property of 'whenDefined' with ssr #24714
Comments
Thanks for the issue. The Action Sheet error was fixed via 897ae4a and a fix will be available in an upcoming release of Ionic. As for the I am trying to understand the
Can you double check your reproduction case and make sure it has all the information I need to run the app? |
@liamdebeasi , thanks for your prompt response and awesome support. The issue you mentioned was due to I added src/environments to the .gitignore. |
Thanks! I have a dev build with the Action Sheet fix:
After installing the dev build, I do not get the action sheet or strict errors. Can you try that dev build and let me know if it resolves the issue? |
Hello Liam, thanks again for your support. I've cloned my repo (I've made for reproduction in my folder, in order to assure it was working, before submitting to you.), tried installing the dev packages, got a dependency error, though (please, find the logs below). I was able to install the dependencies (first the
Please let me know if you need anything else from me, and again, thanks for your support. ps.: I've updated the repo with latest changes ---------- npm install full log
|
Any idea when this will be resolved? It's a bummer not to have SSR. Bing apparently doesn't like rendering SPAs and refuses to index my site |
I often use stencil + ionic with SSG what didn't work anymore with ionic 6. |
It is reproducible by following https://ionicframework.com/blog/ssr-with-angular-universal-and-ionic/ but with the 1. Create the projectionic start myApp sidemenu --type angular
cd myApp
npm install @angular/animations
ng add @nguniversal/express-engine
npm install @ionic/angular-server (you might need to run 2. Enable Ionic SSRAnd updating import { NgModule } from '@angular/core';
import { ServerModule } from '@angular/platform-server';
import { AppModule } from './app.module';
import { AppComponent } from './app.component';
+ import { IonicServerModule } from '@ionic/angular-server';
@NgModule({
imports: [
AppModule,
ServerModule,
+ IonicServerModule
],
bootstrap: [AppComponent],
})
export class AppServerModule {} 3. RunBuild & serve the application with: npm run build:ssr
npm run serve:ssr ( 4. Visit localhost:4000When you visit localhost with javascript off (on chrome,
I hope this helps 🙂 |
I also encounter this issue just like @Tvde1 |
I also get: Using:
Code:
Inside of "connectedCallback" (controllerion-menu_3.entry.js:112) "contentId" is undefined although I did set it. |
Any updates? |
Hi @liamdebeasi are there any work in progress on this issue? Or maybe an idea on how it should be fixed? |
I am encountering the same error. The first time the page loads, the ion-menu works, but on refresh it stops working. package.json ionic info ` Ionic CLI : 6.20.3 (C:\ProgramData\nvm\v18.12.1\node_modules@ionic\cli) Capacitor: Capacitor CLI : 4.6.2 Utility: cordova-res : not installed globally System: NodeJS : v18.12.1 (C:\Program Files\nodejs\node.exe) |
Hi there, Can everyone try the following dev build and let me know if it resolves the issue in your apps?
Please note that this dev build only fixes the |
Yes this works for my case in a pure stencil-ionic app with |
Thanks for the issue. This has been resolved via #26854, and a fix will be available in an upcoming release of Ionic Framework. Please feel free to continue testing the dev build, and let me know if you run into any issues with it. |
Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Ionic, please create a new issue and ensure the template is fully filled out. |
Prerequisites
Ionic Framework Version
Current Behavior
Folks, I'm using the brand new Ionic 6, trying to integrate it with Angular Universal through NestJs. It was working pretty well, until I noted that I was getting this error when running using server side rendering:
Menu: must have a "content" element to listen for drag events on.
After some time, I noticed that the
<ion-menu-button>
wasn't working. I tried using it programmatically using theMenuController
, but it also didn't work.I run the code without SSR and the button was working properly. So I went out to find out what was the issue and I found this issue (#21918 (comment)) where the solution apparently was to add
@ionic/angular-server
to my Angular AppModule. I did so, but now every time I try to access Angular's pages, I'm getting this error (in server console):ReferenceError: Cannot access 'ActionSheet' before initialization
and this one (browser console):
Uncaught SyntaxError: Strict mode code may not include a with statement
I tried to search for those issues but sadly I couldn't find much related.
If I remove
IonicServerModule
from AppModule the code runs, but the button naturally still doesn't work.I'm not sure why this is happening. Is there any error with the Ionic version I'm using? Any substantial package that I'm missing?
From the SSR standpoint I understand that menu's
contentId
looks for its sibling with sameid
as it, and since thatdocument
is not available in that context, in fact, the menu won't have any content at all. But in browser, that doesn't make much sense. I also tried to conditionally render<ion-menu>
tags for platform browsers. TheMenu: must have a "content" element to listen for drag events on.
error disappear, but still<ion-menu-button>
isn't working.Any insights on this matter?
I really appreciate it, thanks in advance.
Expected Behavior
The menu button should work after the implementation of IonicServerModule.
Steps to Reproduce
For reproducing issue with IonicServerModule
npm run dev:ssr
ornpm run serve:ssr
;localhost:4200
.For reproducing issue with
<ion-menu-button>
not working / Menu: must have a "content" element to listen for drag events on.:IonicServerModule
from AppModule (src/app/app.module.ts);npm run dev:ssr
ornpm run serve:ssr
;Code Reproduction URL
https://github.com/vitordhers/confraria
Ionic Info
Ionic:
Ionic CLI : 6.18.1 (/usr/lib/node_modules/@ionic/cli)
Ionic Framework : @ionic/angular 6.0.5
@angular-devkit/build-angular : 13.1.4
@angular-devkit/schematics : 13.1.4
@angular/cli : 13.1.4
@ionic/angular-toolkit : 4.0.0
Utility:
cordova-res : not installed globally
native-run (update available: 1.5.0) : 1.4.1
System:
NodeJS : v16.13.2 (/home/dina/.nvm/versions/node/v16.13.2/bin/node)
npm : 8.1.2
OS : Linux 5.13
Additional Information
Content related with
cannot access "action-sheet" before initialization
:#24448
Content related with
Uncaught SyntaxError: Strict mode code may not include a with statement
:https://stackoverflow.com/questions/60114758/uncaught-syntaxerror-strict-mode-code-may-not-include-a-with-statement
The text was updated successfully, but these errors were encountered: