You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm working on a package and I need to render a component temporarily (like renderToString does) but I need the lifecycle events to occur and emit the updates to a stream. However, I don't need the stdin hooks for escape, Ctrl+c etc. Plus, when I call unmount, I don't want the program to exit.
Right now, as a workaround, I call render(<Component />, {stdout, stdin}) with my stdout being the stream I implement, and stdin being a Noop version of a Readable stream made to look like stdin. To unmount, I have to import call-tree directly and manually unmount, since calling the returned method of render ends my process.
I think implementing a method renderToStream that does the basic functionality without being bound to stdin/stdout is fairly easy, and then render could use that, and add the stdin interactions.
If that sounds like a good idea, I can write a PR.
If there is an easier way to do this that I'm not seeing, let me know.
Also, I think it would make sense to be passing the updated component by itself (without the eraseLine characters that the log-update uses to clear the terminal)
The text was updated successfully, but these errors were encountered:
I'm working on a package and I need to render a component temporarily (like renderToString does) but I need the lifecycle events to occur and emit the updates to a stream. However, I don't need the stdin hooks for escape, Ctrl+c etc. Plus, when I call unmount, I don't want the program to exit.
Right now, as a workaround, I call
render(<Component />, {stdout, stdin})
with my stdout being the stream I implement, andstdin
being a Noop version of a Readable stream made to look like stdin. To unmount, I have to importcall-tree
directly and manually unmount, since calling the returned method ofrender
ends my process.I think implementing a method
renderToStream
that does the basic functionality without being bound to stdin/stdout is fairly easy, and then render could use that, and add the stdin interactions.If that sounds like a good idea, I can write a PR.
If there is an easier way to do this that I'm not seeing, let me know.
Also, I think it would make sense to be passing the updated component by itself (without the eraseLine characters that the
log-update
uses to clear the terminal)The text was updated successfully, but these errors were encountered: