FortAwesome / react-fontawesome

Font Awesome React component
https://fontawesome.com
MIT License
3.67k stars 262 forks source link

Error on `className` with React 19 #560

Closed Arkellys closed 3 months ago

Arkellys commented 3 months ago

Describe the bug

On React 19 (beta), an error is thrown if className is not passed to <FontAwesomeIcon>. I believe it's the same bug as the one reported on this issue, except that now it happens even when no className is specified.

Reproducible test case

https://codesandbox.io/p/sandbox/react-19-font-awesome-k6n8ww?file=%2Fsrc%2FApp.js%3A11%2C51

Error on the sandbox:

TypeError: className is undefined

I get a different error when I try it on my app (maybe it depends on the bundler config):

Uncaught TypeError: Cannot read properties of undefined (reading 'split')

Expected behavior

The error is fixed when adding a className, but this prop should not be required.

Setup

Arkellys commented 3 months ago

I just noticed there is already a PR to fix this, hopefully it will be merged quickly.

robmadole commented 3 months ago

I just released 0.2.1 which I think will fix this. Can you all retest?

sakispirtos commented 3 months ago

i just pulled down 0.2.1 and my application is now showing this error. i had to roll back to 0.2.0 to resolve. I'm using react 18.3.1, font awesome 6.5.2.

with 0.2.1 it wont fail if i supply a className, but my primary use-case doesn't supply unless its needed. Im fine with supplying if thats a new requirement.

Arkellys commented 3 months ago

I just released 0.2.1 which I think will fix this. Can you all retest?

I can confirm that version 0.2.1 solves this issue on React 19, thank you!