Comments (2)
@hhanifkhan: Hello!
In your examples you are passing a prop named focusKey
to your focusable component, but you never pass this value to the useFocusable hook itself - Without this the hook cannot know what you want your focus key value to be, so it automatically generates one.
Basically you are missing this important part that I've commented next to in this example:
const CoolButton = ({focusKey}) => {
const {focused, ref} = useFocusable({
focusKey: 'MY_BUTTONS_FOCUS_KEY' // <-- Add this, hardcode a value to check, or use your focusKey prop!
});
return <button ref={ref} style={{background: focused ? '#f0f' : '#0f0'}}>I'm a button!</>;
};
Now that you've done this the hook will know of this focus key and doing this will work as you expect:
setFocus('MY_BUTTONS_FOCUS_KEY');
Best of luck to you!
Closing this as it's not an issue.
from norigin-spatial-navigation.
Thanks
from norigin-spatial-navigation.
Related Issues (20)
- How can I use 'setKeyMap'? HOT 1
- Demo for android TV HOT 5
- Add a function to set key events HOT 2
- Migration from "styled-components" to "linaria" HOT 1
- using stack navigatior not able to find the focus in react-native-web. HOT 7
- Focus is not Working properly when Stack navigation is Added HOT 1
- The focus is not reaching the intended destination. HOT 6
- Throws error on newest version of lg web os HOT 2
- Test cases HOT 6
- React Native, cannot connect native focus to Norigin focus HOT 2
- Compatibility with WebView in AndroidTV HOT 1
- RTL Flag isn't work HOT 1
- ScrollTo is not Working in Y - axis When Data is Wrapped inside the Row HOT 1
- Allow `ref` on items not yet displayed. (see below for more info)
- Allow for `onArrowPress` to have next focused node as property of KeyPressDetails HOT 1
- Unexplainable behaviour when focusable is removed
- Dynamic RTL switching
- A suggestion about keycode mapping HOT 2
- Scrolling not working HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from norigin-spatial-navigation.