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

No render when combining non-trivial components and having drivers #15

Open
Elvecent opened this issue Jul 13, 2021 · 3 comments
Open
Assignees

Comments

@Elvecent
Copy link

Elvecent commented Jul 13, 2021

Full code here: https://codesandbox.io/s/quirky-butterfly-0pdjd?file=/src/index.ts

function main(sources: any) {
  const counter = Counter(sources, xs.of(2));
  const other = Counter(sources, xs.of(1));
  return {
    react: xs
      .combine(counter.DOM, other.DOM)
      .map((els) => h("div", els))
  };
}

const App = makeComponent(main, {});

render(h(App), document.getElementById("app"));

Given the code above, I get an empty webpage with no components rendered, even though the DOM stream does fire with valid component data.

I can make this work by either removing drivers:

makeComponent(main)

or by replacing my Counter components with something trivial:

.combine(
  xs.of(h("div", "one")),
  xs.of(h("div", "two"))
)

I suspect that there is a bug somewhere in makeComponent code where it branches on non-null drivers argument, but I haven't done any actual investigation.

@staltz
Copy link
Member

staltz commented Jul 13, 2021

The example looks a lot like a glitch to me, see https://staltz.com/rx-glitches-arent-actually-a-problem.html

I've stumbled upon many bug reports that mention some kind of xs.combine(xs.of('A'), xs.of('B')) under the hood, so I would recommend checking the blog post and refactoring your application to avoid diamond shapes. At least it seems like it's a xstream glitch, not an issue specific to @cycle/react.

@Elvecent
Copy link
Author

In fact, using xs.combine(xs.of('A'), xs.of('B')) kind of code in my example does work exactly as I intend. It's the other thing that doesn't, and I don't see how glitches can be a problem here.

@staltz
Copy link
Member

staltz commented Jul 13, 2021

I'll take a look at it sometime soon.

@staltz staltz self-assigned this Oct 26, 2021
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

2 participants