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

Different ways to showcase a value from the CSS file on the console using console.log

In this guide, you can learn how to create a custom directive in Angular by following this tutorial: Custom Directive Tutorial. The directive should function as intended. Still, I want to see the color value set in the CSS file displayed on the console us ...

Swapping JSON: A Quick Guide

When my Angular code loads, a list of buttons (button 1, button 2, button 3, etc.) is displayed. Upon clicking any button, the console shows J-SON with varying values. Two additional buttons are present on the page for moving up and down. My dilemma arise ...

How can you create a type in Typescript that is composed of a specific property taken from another type?

I'm still in the process of understanding typed languages, but imagine I have the following scenario: export interface Person { id: number; name: string; } const persons: Array<Person> = [ { id: 1, name: 'foo', }, { ...

Setting a blank value or null equivalent to a field: Tips and tricks

Here is the component state that I am working with: interface Person { name: string; surname: string; } interface CompState{ //...fields ... person?: Person; } render() { if(this.state.person){ const comp = <div>{this. ...

reinstate dummy of external class method in ts-jest

Problem I am encountering an issue while trying to mock a function that is imported from another class and called within the main class. Although I can successfully mock the function and return the specified values, I am unable to revert the mocked functi ...

Tips for setting up chrome-app typings in Typescript 2

I am looking to eliminate the typings in our Typescript project. After successfully removing most typings dependencies with Typescript 2, I'm left with just one for chrome-app: https://github.com/uProxy/uproxy/compare/master...fortuna:master When usi ...

The process of ordering awaits using an asynchronous method

async fetchAndStoreRecords(): Promise<Records[]> { this.subRecords = await this.afs.collection<Records>('records') .valueChanges() .subscribe((data: Records[]) => { console.log('log before data ...

Using the Vue.js Compositions API to handle multiple API requests with a promise when the component is mounted

I have a task that requires me to make requests to 4 different places in the onmounted function using the composition api. I want to send these requests simultaneously with promises for better performance. Can anyone guide me on how to achieve this effic ...

What is the correct way to implement "next-redux-wrapper" with "Next.js", "Redux-ToolKit" and Typescript?

Currently, I am integrating RTK (redux-toolkit) into my Next.js App. I am facing an issue while trying to dispatch an AsyncThunk Action within "getInitialProps". During my research, I came across a package named "next-redux-wrapper" that allows access to t ...

Allow for an optional second parameter in Typescript type definition

Here are two very similar types that I have: import { VariantProps } from "@stitches/core"; export type VariantOption< Component extends { [key: symbol | string]: any }, VariantName extends keyof VariantProps<Component> > = Extra ...

What could be causing the React Native Error (ReferenceError: Can't locate the variable: React) even though React has been successfully installed?

Issue Summary: I developed a NPM dependency called react-native-ultimate-modal-picker and it has dependencies that need to be properly installed. Desired Outcome: For the package to work correctly, React should be installed since it is required in a new ...

How can I define types for (const item of entries) in Typescript?

I attempted for (const ElementType as element of elements ) {} or for (const ElementType of elements as element) {} However, neither of these options is correct. ...

Eliminate any repeated elements in the array by utilizing TypeScript

Hey, I'm trying to figure out how to remove duplicate entries from an array where the UserId values are the same, and keep only one of each unique entry. Can anyone help me with this? For example: a=[ {userId:1,name:''}, {userId:2,name:&apo ...

Using jQuery with Angular 4 allows for powerful front-end development

To include jQuery in an Angular4 project, I follow these steps: npm install --save jquery npm install --save-dev @types/jquery In the app.component.ts file import $ from 'jquery'; or import * as $ from 'jquery'; When running "ng se ...

Navigating to different HTML pages by utilizing <a> elements in Angular 2

As a newcomer to Angular 2, I've decided to build my personal website using this framework. The main page of my website contains bio information, while the other page will feature blog content. Both pages will have a shared header and footer, but diff ...

Saving JSON data retrieved from the server into an array in Angular 2

Using a nodejs server to retrieve data from an SQL database has been challenging. I attempted to store the data in taches, which is an array of Tache : getTaches(): Observable<Tache[]> { return this.http.get(this.tachesUrl) .map(response => ...

The 'SVGResize' or 'onresize' property is not available on the 'SVGProps<SVGSVGElement>' type

Using React with SVG I'm facing an issue with handling the resizing event of an svg element. I have looked into using the SVGResize and onresize events, but encountered compilation errors when trying to implement them: const msg1 = (e: any) => co ...

Utilize an array of observables with the zip and read function

I'm struggling with putting an array of observables into Observable.zip. I need to create a function that reads values from this dynamically sized array, but I'm not sure how to go about it. Does anyone have any suggestions? import {Observable} ...

Your search parameter is not formatted correctly

I am currently working on filtering a collection based on different fields such as name by extracting the values from the URL parameters. For example: http://localhost:3000/patient?filter=name:jack I have implemented a method to retrieve and convert these ...

The process of incorporating user properties into the output of a Service Bus topic from a Javascript Azure Function

I'm currently developing a TypeScript Azure Function that utilizes an Azure Service Bus topic as its output. Although I am able to send messages successfully, I have encountered difficulties in setting custom metadata properties for the message. In m ...