Why, when using focusSelf inside useEffect, does the focus go to the last item in the list, but when using setFocus it correctly goes to the first item? And what is the solution if I need to use it with focusSelf()?
const Item = ({ item, onEnterPress }) => {
const { ref, focused } = useFocusable({
focusKey: item.focusKey,
onEnterPress: () => {
onEnterPress(item.title);
},
});
useEffect(() => {
setFocus("Main");
}, []);
return (
<MenuItem ref={ref} $focused={focused}>
{item.icon} {item.title}
</MenuItem>
);
};