Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Render expression for every loop cycle #1

Open
VincentDamour opened this issue Jul 7, 2016 · 2 comments
Open

Render expression for every loop cycle #1

VincentDamour opened this issue Jul 7, 2016 · 2 comments

Comments

@VincentDamour
Copy link

VincentDamour commented Jul 7, 2016

The problem

Hi, first of all, thanks for this awesome tool.
I'm trying to render expression for each cycle of a loop, but only the last execution is rendered;

For this example, the output will be New post

const posts = [  { id: '1', text: 'Hello world!' },  { id: '2', text: 'New post' } ];

for (let post of posts) {
  <p>{post.text}</p>
}

Currently I need to use the map function to output each value, like this:

<p>
  { posts.map(post => <p key={post.id}>{post.text}</p>) }
</p>

Here an easier example, the output will be 10:

for (let i = 0; i <= 10; i++) {
  i
}

It would be great if the expression can be outputted for every loop cycle.

@grigio
Copy link

grigio commented Jul 8, 2016

Thank you, I think it is related:

let fn = setInterval(() => {
  console.log('not shown') // OK
  'not shown'
}, 1000)

'shown'

it seems that currently it isn't possible to show in the UI the output of a callback

@StephenGrider
Copy link
Owner

There's no reasonable way to print any values that are generated in an async manner.
The workaround would be to wrap it in a react component

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants