Closed alexpchin closed 3 years ago
I will add more details to this ticket. We should probably also add a check here:
const name = tabNames.value[index]
To ensure that the index
is a valid one.
This does not reproduce in the Example app's "Ref example jumpToTab after 1 second" (which does the same thing).
A more detailed repro would help.
Hi @andreialecu I've added:
React.useEffect(() => {
setTimeout(() => {
// Only seems to happen with `0`
pageRef.current?.setIndex(0);
}, 500);
}, []);
To this PR https://github.com/andreialecu/rnctv-react-native-bare-test/pull/2 Please tell me if you can reproduce.
I can also confirm this happens on the example app when using setIndex(0)
I see.
This only happens if the index
is already the same as the one being set to. It's essentially the same as clicking on the tab bar for the same tab pane.
To clarify, if you increase the timeout to 2500 in your repro and move to index 1 before it sets 0, you'll see that it doesn't hide the header.
I'm not sure if I'd call it a feature or a bug. 🤔
To clarify, you can work around it via:
const index = pageRef.current?.getCurrentIndex();
if (index !== 0) {
pageRef.current?.setIndex(0);
}
Thanks for the clarification @andreialecu
When using
setIndex
the header hides on iOS. You can test by adding something like: