I want to create a basic ScrollView
in which the first page will be visible and it will take the full height of the screen.
When user clicks my button I want to scroll to the second page which will also occupy the full height of the ScrollView
What is the best way to achieve this?
Question posted in React native
The official React Native documentation can be found here.
The official React Native documentation can be found here.
2
Answers
1 – Animation while navigating true screens if you are using react-native-navigation see this
specially this part: "vertical – The gesture to close the screen will start from the top. For animations, screen will slide from the bottom."
2 – With vertical FlatList that scrolls 1 Component per screen size/height (I do not recommend this but it depends on the needs if it’s walkthrough or something similar)
Ps: You are asking for navigation in the title of the question and for scroll in the question so decide what will work best for you.
To achieve a full-screen, scrollable interface where each page takes the full height of the screen, and you can navigate between pages by pressing a button, you can utilize a combination of FlatList and ScrollView. Here’s a step-by-step guide:
1. Define Your Pages: First, outline the structure of each page you want to display. This can be done using an array of objects, each representing a page:
2. Setup FlatList: Use a FlatList to handle the horizontal paging between each full-screen view. Ensure the FlatList is configured to snap to each page and disable scroll indicators for a cleaner look:
The goToNextSlide function is triggered by a button (not shown in the snippet) to navigate to the next page. Remember to replace
<Screen1 />
and<Screen2 />
with your actual component content.This approach provides a smooth, app-like paging experience that can be easily controlled programmatically and is highly customizable to fit your specific needs.