linuswillner/react-console-emulator

[object Object] when dangerMode={true}

Closed this issue · 8 comments

Hi there,

When I set dangerMode={true} with every command I always get:[object Object] echoed back before my content is displayed.

        <Terminal
          dangerMode
          style={termStyle}
          commands={commands}
          welcomeMessage="HISAC Emergency Terminal. Authorised access only!"
          promptLabel={promptLabel}
          autoFocus
          ref={ref}
          noAutoScroll
        />

when any of my commands the [object] [Object] comes up:

[object Object]
Processing...
PRE: DIR: ARCHIVES
PRE: RES: INTENRAL
POS: DIC: INTERFACES
CON: DIC: EXTERNAL
PRE: DIR: CLASSIFIED

It appears to be replacing the "prompt" and the "command" with [object] [Object]

$/ ls

when I press enter, it gets replaced with:

[object] [Object]

Could you show me what your command logic looks like?

may be you trying to do somehitng like :
return terminal.pushToStdout({})
try to use
return terminal.pushToStdout("string here")

for example

I have the same issue with dangerMode.

I would assume it's because constructEcho doesn't return a raw string in

Alright, so, I finally have time to look into this now. I've seen enough forks that fix this issue to the point that I now know where it's coming from. I'll fix it ASAP.

asrvd commented

still not fixed?

bump

I should start by saying this is an awesome component; thanks for your work here @linuswillner!

That said, I have been running in to the aforementioned issue while trying to pipe color output in to the emulator. I've jury rigged a decent solution by converting the escaped color sequences to HTML, and then rendering the resulting markup to an emulator with the dangerMode prop set to true. This works like a ✨ charm, save for the errant [object Object] logline. Weird.

 
Edit: I think I fixed it? Check out #964! 🧐
 

Hi all, sorry for the terribly long wait, life's been way too busy for me to work on a library I first wrote when I was 17 years old, lol. But I am pleased to announce I'm going to fix this bug right now! (Better late than never, I hope)