(Note: I'm using Expo for this app)
I'm attempting to render a FlatList
that displays a list of printers. Here's the code:
<FlatList
data={printers}
keyExtractor={printer => printer.id}
renderItem={({ item }) => {
return (
<Printer
printerTitle={item.name}
selected={item.selected}
last={item === last(printers)}
/>
);
}}
/>
Here's the code for the <Printer />
component:
const Printer = props => {
const { last, printerTitle, selected } = props;
return (
<View style={[styles.container, last ? styles.lastContainer : null]}>
<View style={styles.innerContainer}>
<View style={styles.leftContainter}>
{selected ? (
<Image source={selected ? Images.checkedCircle : null} />
) : null}
</View>
<View style={styles.printerDetails}>
<Text style={styles.printerTitle}>{printerTitle}</Text>
</View>
</View>
</View>
);
};
...
export default Printer;
I can't seem to get the <Printer />
component to render. I have tried including a similar custom component (that has worked in a FlatList
in another part of the app) in the renderItem
prop, and it doesn't work either.
However, when I replace the <Printer />
component with <Text>{item.name}</Text>
component, the printer name renders like I would expect it to.
Has anyone run into this issue before, or does anyone have a solution?