react-console
react-console copied to clipboard
Runtime error is thrown if first command is triggered outside of the component via the public log method
https://github.com/autochthe/react-console/blob/0d5d0834b2131cc86f1fa6342fe3d52130c636ad/src/react-console.tsx#L180
In the case when this.state.log is empty array, JS runtime error is thrown. "Uncaught TypeError: Cannot read property 'message' of undefined"
This is because the log method adds messages to an associated command. At present, if you call log without a command, there is no sensible place to record the message. What is your use case for this functionality? This should only occur before a command is entered. Are you able to use the welcomeMessage
for your purpose?
#8
It is reproducible when there is a welcome message as well. My scenario is that in some cases the first command to the console is triggered from outside. So why not to add the message at index log[0] when this.state.log.length is 0?
I didn't mean to ask if the big was reproducible but if you were l could use the welcome message for your use case. This problem would necessitate a rewrite of the log functionality, so this would only be a temporary workaround.
I'll implement your suggestion later this week, but that too isn't really a proper long term solution.
Will this be fixed? I need to be able to send messages to the console without a command being received first - the main purpose of the console in my app is to display information. The welcome message won't work for this.