2

I'm trying to use an AppBar from React Native Material. The icon i use in the IconButton is from react-native-vector-icon. I have no idea why I'm getting error saying Element type is invalid: expect a string. Check the render method for IconButton as I literally copied the exact code from the React Native Material official doc.

import {AppBar, IconButton} from '@react-native-material/core';
import {Icon} from 'react-native-vector-icons/Entypo';

      <AppBar
        title="Title"
        leading={props => (
          <IconButton
            icon={props => <Icon name="menu" {...props} />}
            {...props}
          />
        )}
      />
Leo
  • 179
  • 9

1 Answers1

3

==> Try My Code it works.

import {AppBar, IconButton} from '@react-native-material/core';
import Icon from 'react-native-vector-icons/Entypo';

      <AppBar
        title="Title"
        leading={props => (
          <IconButton
            icon={props => <Icon name="menu" {...props} />}
            {...props}
          />
        )}
      />
Ankit Vora
  • 568
  • 2
  • 12
  • It works now.. I don't see any difference from my code but it works somehow. Thanks! – Leo Dec 29 '22 at 07:37
  • @Leo WelCome, Please approve my answer and upvote me for motivation. – Ankit Vora Dec 29 '22 at 07:39
  • @Leo the difference is the `Icon` is not a component inside `react-native-vector-icons/Entypo` it's the default export so, when importing don't use curly braces : https://stackoverflow.com/a/36796281/10657559 – Thanhal P A Dec 29 '22 at 08:14
  • 2
    @ZFlocTechnologies Thank you for the clarification! Didn't know that till now, thanks! – Leo Dec 29 '22 at 08:29