Untitled

mail@pastecode.io avatar
unknown
javascript
2 years ago
629 B
3
Indexable
Never

// not good:
function ListUsers() {
    return (
        <Grid container>
            <Grid item>
                <User01 />
            </Grid>
            <Grid item>
                <User02 />
            </Grid>
            <Grid item>
                <User03 />
            </Grid>
        </Grid>
    );
}

// Good :

const ListUsersLayout = ({ children }) => (
    <Grid container}>
        {children.map(child => <Grid item>{child}</Grid>)}
    </Grid>
)

function ListUsers() {
    return (
        <ListUserLayout>
            <User01 />
            <User02 />
            <User03 />
        </ListUserLayout>
    );
}