-1

I have a grid style webpage made with React and I was planning on having one of the grids display system messages e.g. "UP button pressed" when the UP button is pressed.

What is the best way to go about implementing something like that? I have looked into redirecting "console.log" messages and terminal emulators but none really talked about what I was looking for. I was hoping to later be able to export the logs and download them as a text file or something like that.

Xin Wang
  • 3
  • 1
  • Use redux to setup a queue style store, where one component will listen for changes to that store and update the component accordingly. In your specific case, whenever a system message is generated push that system message into the redux store which will update the component :) – Sarhad Salam May 25 '21 at 16:18
  • That is interesting, never heard of redux being used for that. I will research more into that! – Xin Wang May 25 '21 at 16:23

1 Answers1

0

You could use a useEffect hook that listens to keyboard inputs through a listener event, then trigger a modal message or what is you're trying to achieve. Here is an example asked by another user How to register event with useEffect hooks?

momomo
  • 319
  • 1
  • 5
  • 15