Excellent lib! Was thinking it would be nice to be able to programmatically focus a specific element, instead of being at the whims of the layout order. A simple, non-breaking API change could solve this quite nicely, e.g.:
const First = () => {
// Pass an optional 'id' to useFocus
const { isFocused } = useFocus({ id: "first" });
return <Text>{isFocused ? "I am focused" : "I am not focused"}</Text>;
}
const Second = () => {
// Return a 'focus' function that focuses the element with id matching the argument
const { isFocused, focus } = useFocus();
useInput((input) => {
if (input === "f") focus("first");
}, { isActive: isFocused }
);
return <Text>{isFocused ? "I am focused" : "I am not focused"}</Text>;
}
It looks like the machinery is already there, just not exposed in the API. WDYT?
Excellent lib! Was thinking it would be nice to be able to programmatically focus a specific element, instead of being at the whims of the layout order. A simple, non-breaking API change could solve this quite nicely, e.g.:
It looks like the machinery is already there, just not exposed in the API. WDYT?