Say I have a (somewhat contrived component) like this
const ExampleComponent = (props) => {
const renderList = () => {
if (props.list) {
props.list.map((item) => <ListItem {...props.list} />);
} else {
return <div>List Not Found </div>
}
};
return (
<div>
<H1>LIST VIEW</H1>
{renderList()}
</div>
)
};
Is React going to reinitialize that function on every render tick? Should I be worried about that or is it a negligible detail.
Would it be considered to write my component as
const renderList = (list) => {
if (list) {
list.map((item) => <ListItem {...list} />);
} else {
return <div>List Not Found </div>
}
};
const ExampleComponent = (props) => {
return (
<div>
<H1>LIST VIEW</H1>
{renderList(props.list)}
</div>
)
};