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 have been developing a React component using the Mathlive library. The version is 0.97.4. It's a next.js project. Since this is a react implementation of the mathlive library thus I am following this repository as reference. I have also read the official documentation.
I have been getting an warning of Unexpected event type message on both my end as well as running this repo. The warning details is below,
The warning is showing multiple times. If I check the source of the error it's here,
import{RefObject,forwardRef,useCallback,useEffect,useImperativeHandle,useRef}from'react'import{MathfieldElement}from'mathlive'importstylesfrom'./OnScreenKeyboardInput.module.css'import{KEYBOARD_LAYOUT_ALGEBRA}from'./keyboardLayouts.const'interfaceInputKeyboardProps{autoFocus?: booleanisError?: boolean
type: 'number'|'text'
value: string
onChange: (value: string|number)=>voidonEnterPress?: ()=>void}interfaceImperativeHandleProps{focus: ()=>voidblur: ()=>voidsetValue: (newValue: string)=>void}constInputKeyboard=({ onChange, value, type, autoFocus, onEnterPress, isError }: InputKeyboardProps,ref: RefObject<ImperativeHandleProps>,): JSX.Element=>{constinputRef=useRef<MathfieldElement>(newMathfieldElement())useEffect(()=>{constmathInputRef=inputRef.currentif(mathInputRef&&typeofwindow!=='undefined'){// Set fonts and sounds directoryMathfieldElement.fontsDirectory='/fonts'MathfieldElement.soundsDirectory='/sounds'mathInputRef.mathVirtualKeyboardPolicy='manual'// Hide keyboard menumathInputRef.menuItems=[]// Set keyboard layoutwindow.mathVirtualKeyboard.layouts=KEYBOARD_LAYOUT_ALGEBRA// Show keayboardconstshowKeyboard=(): void=>window.mathVirtualKeyboard.show()// Hide keyboardconsthideKeyboard=(): void=>window.mathVirtualKeyboard.hide()// Show keyboard on focusmathInputRef.addEventListener('focusin',showKeyboard)// Hide keyboard on click outsidemathInputRef.addEventListener('focusout',hideKeyboard)return()=>{mathInputRef.removeEventListener('focusin',showKeyboard)mathInputRef.removeEventListener('focusout',hideKeyboard)}}},[])// Manually handle autofocus since mathfield doesn't working with autoFocus.// TODO: Remove this when mathfield support autoFocususeEffect(()=>{if(autoFocus)inputRef?.current?.focus()},[autoFocus])constonEnterPressCallback=useCallback((evt: InputEvent)=>{if(!onEnterPress)returnif(evt.inputType==='insertLineBreak'){onEnterPress?.()evt.preventDefault()}},[onEnterPress],)useEffect(()=>{constinputFieldRef=inputRef.currentif(!inputFieldRef)returninputFieldRef.addEventListener('beforeinput',onEnterPressCallback)return()=>{inputFieldRef.removeEventListener('beforeinput',onEnterPressCallback)}},[onEnterPressCallback])useImperativeHandle(ref,(): ImperativeHandleProps=>{return{focus: ()=>{inputRef?.current?.focus()},blur: ()=>{inputRef?.current?.blur()},setValue: (newValue)=>{inputRef?.current?.setValue(newValue)},}},[],)consthandleMathFieldInput=(evt: React.ChangeEvent<MathfieldElement>): void=>{onChange(evt.target.value)}return(<divclassName={`${styles['input-math-field']}${isError ? styles['is-invalid'] : ''}`}><math-fieldonInput={handleMathFieldInput}ref={inputRef}typeof={type}>{value}</math-field></div>)}constOnScreenKeyboardInput=forwardRef(InputKeyboard)exportdefaultOnScreenKeyboardInput
Do you have any idea why this warning is showing? Surprisingly, this warning is only showing when I am using the React Developer Tool extension. Also, could you please check if my implementation is okay.
Thanks!
The text was updated successfully, but these errors were encountered:
Hi,
I have been developing a React component using the Mathlive library. The version is
0.97.4
. It's a next.js project. Since this is a react implementation of the mathlive library thus I am following this repository as reference. I have also read the official documentation.I have been getting an warning of
Unexpected event type message
on both my end as well as running this repo. The warning details is below,The warning is showing multiple times. If I check the source of the error it's here,
Here is my implementation.
Do you have any idea why this warning is showing? Surprisingly, this warning is only showing when I am using the React Developer Tool extension. Also, could you please check if my implementation is okay.
Thanks!
The text was updated successfully, but these errors were encountered: