Skip to content
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

Invalid prop style of type array supplied to FontAwesomeIcon, expected object #40

Closed
genesy opened this issue Dec 13, 2019 · 6 comments
Closed

Comments

@genesy
Copy link

genesy commented Dec 13, 2019

Describe the bug
Warning message appears on simulator/console when clicking/tapping the icon when wrapped in a Touchable component

Reproducible test case

import React from 'react';
import { FontAwesomeIcon } from '@fortawesome/react-native-fontawesome';
import { faHeart } from '@fortawesome/free-regular-svg-icons';
import { TouchableHighlight, View } from 'react-native'

export default () => (
  <View>
    <TouchableHighlight onPress={()=> {}} style={{padding: 50}}>
      <FontAwesomeIcon icon={faHeart}/>
    </TouchableHighlight>
  </View>
)

dep versions from package.json

    "@fortawesome/react-native-fontawesome": "^0.1.0",
    "@fortawesome/free-regular-svg-icons": "^5.12.0",
    "expo": "^36.0.0",
    "react": "16.9.0",
    "react-native": "0.61.4",

run this file on new react native project and the error should show when you tap

Expected behavior
No warning message spam

Desktop (please complete the following information):

  • Android simulator 8.1

Additional context
Was reported on a different github repo here
FortAwesome/react-fontawesome#245

@leurs247
Copy link

leurs247 commented Dec 17, 2019

I have the same error. I don't get the error on every screen. My expected behavior is no warning message. The warning message shows up on iOS (11.4), not in android.

@likern
Copy link

likern commented Dec 24, 2019

This is a cruicial bug, because if styled-components package is used (1,211,309 downloads/week) it automatically converts css properties to array of styles (at compile-time):

<FontAwesomeIcon
  css={`
    margin-left: 14px;
  `}
  icon={['fal', iconName]}
  size={24}
/>

@likern
Copy link

likern commented Jan 28, 2020

For everyone for whoom this bug is cruicial might check out might forked project - https://github.com/breeffy/react-native-svg-icons

There is an added support for arrays. styled-components are working out of box.

@jdcookie
Copy link

Seems like a temporary work around until a proper fix is done, it to wrap the FontAwesomeIcon component in a Fragment.

<TouchableHighlight onPress={() => {})>
  <>
    <FontAwesomeIcon icon={['fas', 'heart']} />
  </>
</TouchableHighlight>

I am using styled-components and was seeing the exact issue described above.

@robmadole
Copy link
Member

I'm going to work with @puremana to try and get his PR merged

@robmadole
Copy link
Member

0.2.3 released to support arrays (thanks @puremana)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants