-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Load content of tab when pressing tab instead load all tabs #2331
Comments
have you tried the "lazy" property ? |
@SoldierCorp currently I don't believe there is way to render the tab "new" every time you go to the tab, if you are looking for just when you initially go to a tab for the first time, then @Nautal has the right idea of using the |
@SoldierCorp Did you find any solution? I am having the same problem, I want to fetch the data of a second tab only when this tab is active. |
@Nautal I cannot see any difference using lazy @mcabs3 I want to know if there is a way to detect the tab event to compare if the content has not been loaded, then load the content because I'm using axios to get data from my API @pgonzalez-santiago Not yet u.u |
Why don't use onEnter?
… 6 сент. 2017 г., в 17:20, Edgardo Ramírez ***@***.***> написал(а):
@Nautal I cannot see any difference using lazy
@mcabs3 I want to know if there is a way to detect the tab event to compare if the content has not been loaded, then load the content because I'm using axios to get data from my API
@pgonzalez-santiago Not yet u.u
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or mute the thread.
|
@SoldierCorp I added the prop "lazy" in the tabs parent and it works. Fetch data in the componentDidMount() on my second tab is called when I navigate into it. I think this is what you want. |
@aksonov I'll check how to use it, thank you! @pgonzalez-santiago That's weird, I have that prop and componentDidMount but all of them are being loaded at the same time. |
@SoldierCorp Could you paste the code of your scenes/tabs please? |
|
lazy must be defined for Tabs, not for scene, please carefully check docs... |
Actually if you check the docs, lazy is in the Scene not in Tabs, please review that part https://github.com/aksonov/react-native-router-flux/blob/master/docs/API.md |
I've set lazy="true" in my scene but it still loads the componentDidMount method. How can we fix this? |
Read docs carefully. |
Ok, sorry about that I found a fix! The lazy attribute is in fact working. My problem was coming from the fact that I was calling a onPress={this.connectWithFacebook()} instead of onPress={() => this.connectWithFacebook()} which was calling the function automatically. If this can help anyone in the future. Sorry about that! |
@hugoh1995 so , is "lazy" a solution to get rid of this problem ? I have similar problem , my app is like land on signin page first and then after logged in user lands to 4tabs e.g. news , photos , videos and other , when user successfully logged in , it takes around 3-4 seconds pause from landing signin page to tab group because big heap of data is fetched , renders along with images , so I want user when he lands on main tabs which is news only this data should be loaded , rest of other 3 tabs data should get whenever we hit on them. |
Lazy Loading Tab Content in React Bootstrap: Implementing lazy loading for tab content in React Bootstrap allows you to load the content of a specific tab only when that tab is clicked. This approach optimizes performance by avoiding the upfront loading of all tab content at once (avoid all tabs API response). Utilizing conditional rendering based on the active tab ensures that only the selected tab's content is displayed, providing a more efficient and responsive user experience. The example code demonstrates how to achieve lazy loading using the Tabs and Tab components in React: const [activeTab, setActiveTab] = useState('tab1');
|
Version
Tell us which versions you are using:
Expected behaviour
Actual behaviour
The text was updated successfully, but these errors were encountered: