activeSales: null,
loading: true,
loadCount: 10
}}
didMount={async ({ state, setState }) => {
const respActiveSales = await fetch(
${BASE_URL}/project?count=${state.loadCount},
{
method: "GET",
headers: {
"Content-Type": "application/json"
}
}
);
try {
if (respActiveSales.ok) {
const respValue = await respActiveSales.json();
setState({ activeSales: respValue, loading: false });
}
} catch (e) {
console.log(e);
}
}}
>
{({ state, setState }) => (
<Fragment>
{state.loading ? (
<div>Loading</div>
) : state.activeSales ? (
state.activeSales.map(ActiveSalesList)
) : null}
<button onClick={setState({ loadCount: state.loadCount + 10 })}>
Load more
</button>
</Fragment>
)}
</Component>
Renderless Containers из react-powerplug юзаешь?
Обсуждают сегодня