I’m making themed ui components and it’s worked great until I got to icons. I am running into a weird error.
This works
import React from 'react';
import { Platform, TouchableHighlight } from 'react-native';
import { MaterialCommunityIcons as Icon } from '@expo/vector-icons';
const LeftDrawerMenuButton = ({ navigation }) => (
<TouchableHighlight
onPress={() => {
navigation.navigate('DrawerOpen');
}}
>
<Icon name="menu" size={24} style={{ padding: Platform.OS === 'ios' ? 10 : 16 }} />
</TouchableHighlight>
);
export default LeftDrawerMenuButton;
This is broken
import React from 'react';
import { Platform, TouchableHighlight } from 'react-native';
import { MaterialCommunityIcons as Icon } from '@expo/vector-icons';
const LeftDrawerMenuButton = ({ navigation }) => (
<TouchableHighlight
onPress={() => {
navigation.navigate('DrawerOpen');
}}
>
<ThemedIcon />
</TouchableHighlight>
);
const ThemedIcon = () => (
<Icon name="menu" size={24} style={{ padding: Platform.OS === 'ios' ? 10 : 16 }} />
);
export default LeftDrawerMenuButton;
The phone says this:
And the console says this:
Warning: Stateless function components cannot be given refs (See ref “childRef” in ThemedIcon created by TouchableHighlight). Attempts to access this ref will fail.
My Google-foo is weak on this one. Thanks for any help being pointed in the right direction!