Skip to content

React Components should support className #17962

Closed

Description

@tonypee
"@ionic/react": "^0.0.5",
"typescript": "^3.3.3"
"@types/react": "^16.8.4",

There is a bug with using 'className' on most components (IonCard,IonButton, Ion...)

<IonCard  className="myCard">...</IonCard>

errors:
Property 'className' does not exist on type 'IntrinsicAttributes & Pick<IonCardAttributes & { ref?: RefObject<HTMLIonCardElement>; children?: ReactNode; }, "hidden" | "dir" | "slot" | "style" | "title" | "contextmenu" | ... 157 more ... | "onTransitionEndCapture"> & RefAttributes<...>'.ts(2322)

Activity

  1. tonypee commented on Apr 4, 2019

    @tonypee
    Author

    It seems that the root of this, is in the stencil library where the definition of JSX.HTMLAttributes only allows 'class' not 'className'.

    React may soon support className AND class . (react/react#13525 (comment)).

    I guess you have decided 'class' is the way of the future, or more cross platform (which is true). It may be a stumbling block for many react developers however.

    solution: USE CLASS

    <IonCard  class="myCard">...</IonCard>
    
  2. reopened this on Apr 4, 2019
  3. tonypee commented on Apr 4, 2019

    @tonypee
    Author

    Since React doesn't yet support class, would it make sense to allow className on that platform? Otherwise im mixing the two attributes depending on the element

  4. tonypee commented on Apr 5, 2019

    @tonypee
    Author

    Im finding that styling the IonCard at all (via class or className (typing as any)) produces unexpected renders. My dom is rendering visibilities incorrectly. Maybe the way class integrates with react currently is unsupported, and therefore stencil's approach is dangerous. more testing is needed

  5. changed the title [-]React Components should extend HtmlDivElement[/-] [+]React Components should support className[/+] on Apr 5, 2019
  6. SulimanTwfiq commented on Apr 8, 2019

    @SulimanTwfiq

    i have the same issue. CSS in JS doesn't work too.

  7. self-assigned this
    on Apr 18, 2019
  8. added
    package: react
    on Apr 18, 2019
  9. jthoms1 commented on Apr 18, 2019

    @jthoms1
    Contributor

    I am going to create some tests around being about support className and css in js solutions. Leaving this open as a bug to ensure I have a narrative on how they can be used.

  10. elylucas commented on May 8, 2019

    @elylucas
    Contributor

    Fixed in #18231. Thanks!

  11. ionitron-bot commented on Jun 7, 2019

    @ionitron-bot

    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.

  12. locked and limited conversation to collaborators on Jun 7, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

package: react

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions