Created
June 25, 2026 11:12
-
-
Save cgoldsby/aa0e9969e47f766ee482e518071f6289 to your computer and use it in GitHub Desktop.
Focus/Blur event order test for react-native-tvos #1133
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import React, {useState} from 'react'; | |
| import {Pressable, Text, View} from 'react-native'; | |
| let seq = 0; | |
| export default function FocusOrderTest() { | |
| const [log, setLog] = useState([]); | |
| const add = s => { | |
| const line = `[FocusOrder] #${++seq} ${s}`; | |
| console.log(line); | |
| setLog(prev => [line, ...prev].slice(0, 20)); | |
| }; | |
| const btn = title => ( | |
| <Pressable | |
| onFocus={() => add(`Focus: ${title}`)} | |
| onBlur={() => add(`Blur: ${title}`)} | |
| style={({focused}) => ({ | |
| padding: 10, | |
| margin: 4, | |
| borderRadius: 6, | |
| backgroundColor: focused ? '#2563eb' : '#334155', | |
| })}> | |
| <Text style={{color: '#fff', fontSize: 13}}>{title}</Text> | |
| </Pressable> | |
| ); | |
| return ( | |
| <View style={{flex: 1, padding: 16}}> | |
| <View style={{flexDirection: 'row'}}>{btn('A')}{btn('B')}</View> | |
| {log.map((l, i) => ( | |
| <Text key={i} style={{fontFamily: 'Menlo', fontSize: 11}}>{l}</Text> | |
| ))} | |
| </View> | |
| ); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment