This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
import AsyncSelect from 'react-select/async'; | |
export default function PageComponent() { | |
const mapResponseToValuesAndLabels = (data) => ({ | |
value: data.id, | |
label: data.name, | |
}); | |
async function callApi(value) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { useState } from 'react'; | |
import AsyncSelect from 'react-select/async'; | |
export default function PageComponent() { | |
const INITIAL_DATA = { | |
value: 0, | |
label: 'Selecione o usuário', | |
}; | |
const [selectData, setselectData] = useState(INITIAL_DATA); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
useEffect(() => { | |
const listElement = refElement.current; // this is a ref that you need to pass to your html element that contains scroll | |
if (listElement) { | |
listElement.onscroll = () => { | |
const bottom = listElement.scrollHeight - listElement.scrollTop === listElement.clientHeight; | |
if (bottom) { | |
onEndReached(); // it is a prop you can change per a inside component method | |
} | |
}; |