Skip to content

Passing props to a wrapped component #205

Answered by brainkim
darrylcousins asked this question in Q&A
Discussion options

You must be logged in to vote

It looks like both in the reproduction and in your actual code, you’re not updating the props to latest in either the wrapper or wrapped function.

function wrap(Component) {
  return function *(props) {
    for (props of this)
      yield <Component {...props} />;
  };
}

async function *Wrapped({count}) {
  for await ({count} of this) {
    console.log('counting in Wrapped Component', count); // does not refresh
    yield <div>My count is {count}</div>;
  };
}

const MyComponent = wrap(Wrapped);

function *App() {
  let seconds = 0;
  const interval = setInterval(() => {
    seconds++;
    this.refresh();
  }, 1000);

  try {
    for ({} of this) {
      console.log('counting in App', se…

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@darrylcousins
Comment options

@brainkim
Comment options

Answer selected by brainkim
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants