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.

class keyword is not working properly, but className is in React-Grid-Layout.

See original GitHub issue

Hello,

I do like the naming of class in Preact instead of className in React.

On using react-grid-layout below, it seems that class keyword in tag affects properly in react-grid-layout. But, className keyword does not… https://github.com/STRML/react-grid-layout

I set the value of layout in graphContainer.css. class keyword is not applied…

import { h, Component } from 'preact';
import style from './graphContainer.css';
import GridLayout from 'react-grid-layout';

class GraphContainer extends Component{
  render() {
    return (
      <GridLayout className="layout" cols={12} rowHeight={30} width={1200}>
        <div key="a" data-grid={{x: 0, y: 0, w: 1, h: 2, static: true}}>a</div>
        <div key="b" data-grid={{x: 1, y: 0, w: 3, h: 2, minW: 2, maxW: 4}}>b</div>
        <div key="c" data-grid={{x: 4, y: 0, w: 1, h: 2}}>c</div>
      </GridLayout>
    )
  }
}

Do I have to use className out of preact?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
kidquebcommented, Jan 10, 2019

If you’re using css modules it may be that the styles just aren’t being referenced.

import style from './graphContainer.css';

...

<GridLayout class={style.layout} cols={12} rowHeight={30} width={1200}>

The difference being class={style.layout} instead of className="layout"

1reaction
developitcommented, Dec 26, 2018

You need to pass the name that the library expects - preact doesn’t normalize between the names except when applying props to DOM elements.

If GridLayout expects to be passed className="x", you have to pass it that way.

You might find Preact Compat addresses this - it installs className as an alias of class.

Read more comments on GitHub >

github_iconTop Results From Across the Web

class keyword is not working properly, but className ... - GitHub
Hello, I do like the naming of class in Preact instead of className in React. On using react-grid-layout below, it seems that class...
Read more >
Why We Don't Use Class Keyword in React? - YouTube
Why We Don't Use Class Keyword in React? | ClassName Keyword Explained #shorts. 9.9K views 1 year ago. codedamn. codedamn. 336K subscribers.
Read more >
react-grid-layout-multi - npm
A draggable and resizable grid layout with responsive breakpoints, for React. Fork of original.. Latest version: 1.0.1, last published: a ...
Read more >
React grid layout not working with firebase - Stack Overflow
In the original code, the images are all in a row however now they are all in one column. I am not too...
Read more >
What does the className attribute mean in JSX?-Reactjs
In vanilla JavaScript className is used to assign classes because the class keyword makes a different type of class. M. Carr 107. Source:...
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