Tips for detecting the end of a scroll view in a list view

I've encountered an issue with my scrollView that allows for infinite scrolling until the banner or container disappears. What I'm aiming for is to restrict scrolling once you reach the last section, like number 3, to prevent the name part from moving, allowing only the chart to be scrolled.

You can experience this in Expo-Snack by clicking on the following link:

Here's an excerpt of the code:

NewTableScree.tsx:

    const dataDummy = [
    {
        key: 1,
        name: "Tommy",
        chart: "10",
        char2: "20",
        chart3: "30",
        number: "100",
        number2: "2000",
        number3: "2000", 
    },
    {
        key: 2,
        name: "William",
        chart: "10",
        char2: "20",
        chart3: "30",
        number: "100",
        number2: "2000",
        number3: "2000", 
    },
    {
        key: 3,
        name: "Robert",
        chart: "10",
        char2: "20",
        chart3: "30",
        number: "100",
        number2: "2000",
        number3: "2000", 
    }
]

const renderChart = ({ item }) => (
    <>
      <Div
        py={14}
        bg="white"
        row
        borderBottomWidth={1}
        borderColor="#c4c4c4"
        rounded={0}
        
      >
        {/* 
        <Div flex={3}>
          <Text fontWeight="normal" textAlign="center" >
            {item.name}
          </Text>
        </Div> */}
        <Div flex={3}>
          <Text fontWeight="normal" textAlign="center">
            {item.chart}
          </Text>
        </Div>
        <Div flex={3}>
          <Text fontWeight="normal" textAlign="center">
            {item.char2}
          </Text>
        </Div>
        <Div flex={3}>
          <Text fontWeight="normal" textAlign="center">
            {item.chart3}
          </Text>
        </Div>
        <Div flex={3}>
          <Text fontWeight="normal" textAlign="center">
            {item.number}
          </Text>
        </Div>
        <Div flex={3}>
          <Text fontWeight="normal" textAlign="center">
            {item.number2}
          </Text>
        </Div>
        <Div flex={3}>
          <Text fontWeight="normal" textAlign="center">
            {item.number3}
          </Text>
        </Div>
      </Div>
    </>
  )

const renderSingle = ({ item }) => (
    <>
      <Div
        py={14}
        bg="white"
        row
        borderBottomWidth={1}
        borderColor="#c4c4c4"
        rounded={0}
        
      >
        <Div flex={3}>
          <Text fontWeight="normal" textAlign="center" >
            {item.name}
          </Text>
        </Div>
      </Div>
    </>
  )

// More code here...

export default NewTabelScreen

If anyone has a solution to my problem, it would be greatly appreciated. Thank you very much!

Answer №1

The FlatList component is displaying with a large right margin.

<FlatList
  style={{ 
    width: windowWidth, 
    marginRight: heightPercentageToDP(50) // consider removing this line!
  }}
...

By removing the 'marginRight' property, the component should behave as intended.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Barreling is essential for TypeScript custom paths to function properly

This morning has been dedicated to exploring ts-paths in order to shorten my import paths. After some experimentation, I have found that custom paths do work IF you set up barreling (having an index file that exports your modules) root ├── client ...

Utilize the onChangeText function in React Native to filter out each individual value within a nested array

I currently have an array with nested children in it, where the children can range from one to multiple values. I am working on implementing a local filter within my component. Whenever a user types anything into the textInput, the application will display ...

Navigating a relative path import to the correct `@types` in Typescript

When the browser runs, I require import * as d3 from '../lib/d3.js'; for d3 to be fetched correctly. I have confirmed that this does work as intended. However, the file that contains the above code, let's call it main.js, is generated from ...

How to resolve useState problem in useEffect when state is not null

Encountering issues with maintaining state in TypeScript React. A Child component passes a 'terminal' object to the Parent via a function called returnTerminal(). This 'terminal' object is then stored as a useState variable named _obje ...

Changing Text in React Native is Customizable

As a newcomer to react native, I find myself in need of some guidance. I am currently working on implementing a TextInput feature where users can update the text value as they please. For instance, if a user initially creates a folder named "Bar" but later ...

Having Trouble Adding Details to a New Cart for a User in Angular and MongoDB - What's Going On?

After working on an E-Commerce site for a while, I hit a roadblock. Despite taking a break and coming back with determination, I can't seem to resolve the issue at hand. The application features registration, login, product search, and a popup window ...

Where's the tsconfig.json for Firebase Emulators?

I've encountered an issue with my Firebase project that's written in JavaScript (not TypeScript). When attempting to run the functions emulator, I'm getting the following error: $ firebase emulators:start --only functions ⚠ functions: Ca ...

Leverage Angular2 validators beyond FormControl's limitations

As I work on developing a model-driven form in Angular2 RC5, one of the features I am implementing is the ability for users to add multiple entries either manually or by importing from a file. To display the imported data in a table, I utilize JavaScript t ...

Is there a way to determine the quantity of lines within a div using a Vue3 watcher?

Is it feasible to determine the number of text lines in a div without line breaks? I am looking to dynamically display or hide my CTA link based on whether the text is less than or equal to the -webkit-line-clamp value: SCRIPT: const isExpanded = ref(true ...

What is the proper way to implement Firebase getDoc in Vue with vue-concurrency?

I am currently in the process of developing a TypeScript Vue composable that utilizes Firebase and the vue-concurrency library. According to the documentation, I need to explicitly type any intermediate values that are yielded. I am facing a challenge wh ...

Angular 8: How to Filter an Array of Objects Using Multiple Conditions

I am faced with the following scenario where I need to filter an array of objects based on lineId, subFamily, and status. My current code successfully filters based on lineId, but now I also need to include a condition for subFamilyId. I have two specifi ...

The issue of TypeError arising while invoking a method within TypeScript Class Inheritance

Currently, I am developing a Node.js application with TypeScript. In this project, I have a base controller class named BaseController and a derived controller called SettingController. The intention is for the SettingController to utilize methods from the ...

Trouble encountered while setting up Firebase Auth for React Native by utilizing AsyncStorage

Trying to implement SMS authentication via Firebase has presented some challenges for me. Despite poring over the documentation and scouring Google for solutions, I've hit a dead end. My setup is pretty basic - just a single input field and a "Send" b ...

The error code TS2345 indicates that the argument type 'Event' cannot be assigned to a parameter type 'string'

Hello, I'm a newcomer to utilizing Angular and I'm struggling to identify where my mistake lies. Below is the TypeScript code in question: import { Component } from '@angular/core'; @Component({ selector: 'app-root' ...

Sending a parameter to a confidential npm module

I've developed a custom npm module that can be used in my applications by including this code snippet in the HTML: <app-header-name></app-header-name> Here is the TypeScript code inside the npm package: import { Component, OnInit } from & ...

Retrieve an array of specific column values from an array of objects using Typescript

How can I extract an array from an array of objects? Data var result1 = [ {id:1, name:'Sandra', type:'user', username:'sandra'}, {id:2, name:'John', type:'admin', username:'johnny2'}, ...

cookies cannot be obtained from ExecutionContext

I've been trying to obtain a cookie while working with the nestjs and graphql technologies. However, I encountered an issue when it came to validating the cookies by implementing graphql on the module and creating a UseGuard. It was suggested that I ...

Omit select dormant modules when building (Angular5)

Currently, I am collaborating on a project that is being implemented across various customer instances. Within the project, we have several lazy loaded modules, with most of them being utilized by all customers. However, there are certain modules that are ...

Is it possible to establish a specific many-to-many relationship using Prisma?

In the Prisma documentation, it states that the set function can be used to override the value of a relation. const user = await prisma.user.update({ where: { email: '<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="73121f ...

Challenges of implementing dark mode with a checkbox and local storage

I'm experiencing an issue with local storage. When I enable the dark mode, everything functions properly and the local storage 'dark' is set to true. However, upon refreshing the page, the local storage remains true but the toggle switches b ...