Replies: 2 comments
-
Does you code highlight an issue or bug in the WEBMIDI.js library itself? If not, it would be more appropriate to post it to the discussions area. |
Beta Was this translation helpful? Give feedback.
0 replies
-
Since I haven't heard back from you, I'm going to move your message to the Discussions section (Q&A). |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I am trying to keep track of MIDI messages received from the listener for
midimessage
but it seems I am unable to access state or refs for the current component from within the listener. I am trying to keep track of which notes have been received from a specific device so that I can compare against the available notes and figure out what hasn't been played yet. No error messages are present in the console.I initialize the WebMIDI instance in a custom hook and return both the WebMIDI instance and the connected device
In this first example, the callback function fires on every MIDI message as expected but the state boolean never gets updated.
In this second example, the contents of the ref are available inside the callback function and I can update it correctly but functions outside of the callback only see the unmodified ref contents.
EDIT:
I forgot to mention that both state and refs are correctly updated when I set up a dummy keyboard event listener on the document object as a control test
Environment:
Libarary version: CJS
Runtime: Browser, Next.js 12
Language: TypeScript
OS: Windows 10 22H2 build 19045.3324
Beta Was this translation helpful? Give feedback.
All reactions