When returning the below in a component to render cards where would you put a filter on something like this?
{state.messages.map((message, index) => (
<div key={index}>
<Center>
<Box
maxW={'850px'}
w={'full'}
boxShadow={'2xl'}
rounded={'md'}
p={6}
overflow={'hidden'}
>
<Flex>
<h4>UserID: {message.id}</h4>
<Spacer/>
<Button onClick={'test'} colorScheme='teal' variant='solid' >
<DeleteIcon/>
</Button>
</Flex>
<h3>User(email for now): {message.user} </h3>
<h2 >message: {message.message}</h2>
<p>Date: {message.createdAt}</p>
</Box>
</Center>
<Container height={50}/>
</div>
))}
My first thought was something like
{state.messages.filter((message) => message.id).map((message, index) => (...
this doesn't return anything but a regular map so not it probably just an example
...}
So hoping someone can explain what best practice is for filtering a map in returned jsx. can you even do what I'm trying to do without callstack errors?
edit: someone said the snippet is the right way, so i'll fix it in the morning and update/close this. if anyone else wants to confirm overnight too many thanks