question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

bug: property style doesn't work on root IonPage

See original GitHub issue

Prerequisites

Ionic Framework Version

  • v4.x
  • v5.x
  • v6.x

Current Behavior

Property style doesn’t passing through an IonPage component

Expected Behavior

Property style should be passing to the actual IonPage element get rendered on the DOM

Steps to Reproduce

minimal ionic-react code

import { IonApp, IonContent, IonHeader, IonPage, IonTitle, IonToolbar, setupIonicReact } from '@ionic/react'
import '@ionic/react/css/core.css'
import { createRoot } from 'react-dom'

setupIonicReact()

createRoot(document.getElementById('root')).render(<IonApp>
  <IonPage style={{ backgroundColor: 'black !important' }}>
    <IonHeader>
      <IonToolbar>
        <IonTitle>My Title</IonTitle>
      </IonToolbar>
    </IonHeader>
    <IonContent>
      Hello World
    </IonContent>
  </IonPage>
</IonApp>)

Code Reproduction URL

https://github.com/natqe/ionic-page-style-not-working/

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
sean-perkinscommented, Jan 6, 2022

@natqe thanks for the reproduction!

This appears to be an issue with the root IonPage instance. If you have a nested IonPage, the inner instance appropriately applies inline styles.

This looks to be a flaw with the IonPage react implementation.

To work around this issue, you can specify className and it will apply correctly:

<IonApp>
  <IonPage className="my-custom-class">
    ..
  </IonPage>
</IonApp>
.my-custom-class {
  background-color: black;
}

I’ll track this issue as a bug with react & we will prioritize in upcoming sprints or downtime. Thanks!

0reactions
ionitron-bot[bot]commented, Aug 28, 2022

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

TS2339: Property 'style' does not exist on type 'Element'
You need a typecast: Array.from(document.getElementsByClassName('mat-form-field-infix') as HTMLCollectionOf<HTMLElement>).
Read more >
ion-modal: Ionic Mobile App Custom Modal API Component
ion-modal is a dialog that appears on top of mobile app content, and must be dismissed before interaction resumes. Learn more about custom...
Read more >
9 Common Problems in Windows 8.1 | Network Wrangler
This problem seems to derive from a bug between the OS and a hardware driver of installed software. The problem usually comes from...
Read more >
Ionic Modal In Vue JS, Managing Events - DEV Community ‍ ‍
This post is kinda old, there is a full example on using IonModal Here No TS Ionic Vue Example If you have issues...
Read more >
Property 'style' does not exist on type 'Element' in TS
The error "Property 'style' does not exist on type 'Element'" occurs when we try to access the `style` property on an element that...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found