Skip to content

Keyboard and Mouse events on views not working #2781

@Roshan-24

Description

@Roshan-24

Environment

react-native -v: 
18.0.0

npm ls react-native-macos:
RnMacOSBarebones@0.0.1 /Users/roshanbx/Projects/POC/RnMacOSBarebones
└── react-native-macos@0.79.1

node -v:
v22.17.1

npm -v:
10.9.2

yarn --version:
zsh: command not found: yarn

xcodebuild -version:
Xcode 26.0.1
Build version 17A400

Steps to reproduce the bug

  1. Run npx @react-native-community/cli init <projectName> --version 0.79.6
  2. cd into project and run npx react-native-macos-init
  3. Replace App.tsx with following code
import { useEffect, useRef, useState } from 'react';
import { View, Text, TextInput } from 'react-native';

function App() {
  const boxRef = useRef<View | null>(null);
  const [text, setText] = useState("Yes");

  useEffect(() => {
    boxRef.current?.focus();
  }, [])

  return (
    <View>
      <View ref={boxRef} focusable={true} style={{ width: 100, height: 100, backgroundColor: 'red' }} onMouseEnter={() => setText("hello")} onMouseLeave={() => setText("Yes")} onKeyDown={() => setText("keyDown")} />
      <Text>{text}</Text>
      <TextInput keyDownEvents={[{ key: 'u' }]} onKeyDown={() => setText("keyDowns")} />
    </View>
  );
}

export default App;
  1. Run npx react-native run-macos

Expected Behavior

The text state should change when I hover my mouse into and out of the red 100x100 box view, and when i start typing in the textInput and during keyDown when the box is focused

Screen.Recording.2025-12-19.at.12.50.22.mov

Actual Behavior

The text state does not change, from which I infer that the mouse and keyboard events are not working.

The exact same code does provide the expected results on windows however (react-native@0.79.4 and react-native-windows@0.79.4)

Screen.Recording.2025-12-19.at.12.51.50.mov

Reproducible Demo

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions