Difference between revisions of "Loop"
From SocialStack
| Line 2: | Line 2: | ||
=Sample Usage= | =Sample Usage= | ||
Simple loop over everything of a given type (user in this case). Note that it will always be restricted by what you are permitted to see. | |||
<syntaxhighlight lang="dart" line="1"> | |||
<Loop over='user/list'> | |||
{ | |||
user=> { | |||
return <p>{user.username}</p>; | |||
} | |||
} | |||
</Loop> | |||
</syntaxhighlight> | |||
<syntaxhighlight lang="dart" line="1"> | <syntaxhighlight lang="dart" line="1"> | ||
| Line 16: | Line 31: | ||
{ | { | ||
page => { | page => { | ||
return page.title; | return <p>{page.title}</p>; | ||
} | } | ||
} | } | ||
Revision as of 15:26, 9 November 2021
<Loop> is a very commonly used React component installed by default in SocialStack projects. It is used to loop over lists of items typically from the API.
Sample Usage
Simple loop over everything of a given type (user in this case). Note that it will always be restricted by what you are permitted to see.
<Loop over='user/list'>
{
user=> {
return <p>{user.username}</p>;
}
}
</Loop>
<Loop over='page/list' filter={
{
where: {
url: {
startsWith: '/en-admin/'
}
}
}
}>
{
page => {
return <p>{page.title}</p>;
}
}
</Loop>