我试图使用nextFocusRight停止从React Native中的最后一个元素传播焦点,但是焦点仍传播到下一个视图。根据此拉取请求,它应该可以工作,但仍然面临相同的问题
我的代码:App.js
export default class App extends Component {
render() {
const data = [];
for (let i = 0; i < 10; i++)
data.push(i);
return (
<View>
<View>
{[1, 2].map(() => (
<ScrollView horizontal style={{ height: 210 }}>
{data.map(i => <Item id={i} buttonRef={this.buttonRef} />)}
</ScrollView>
))}
</View>
</View>
);
}
}
Run Code Online (Sandbox Code Playgroud)
Item.js
export default class Item extends Component {
myRef = null;
componentDidMount() {
const { id } = this.props;
if (id == 0) {
this.myRef.setNativeProps({ …Run Code Online (Sandbox Code Playgroud)