npm-lazy

Make 2nd API calls when all contents are loaded (lazy loading) from the first API call in React js

走远了吗. 提交于 2019-12-02 09:04:34
问题 I have some .json files. I need to show all the data from the first .json file in browser as lazy loading.I need to make API call to the second .json when all contents are loaded from the first .json file (when user scoll to end of the page) . I should not make all API call at a time. How to do this using react js. 回答1: Make use of javascript scroll eventListener and calculate the window scroll height in order to trigger the async call. Please bind the necessary method in the constructor and

Make 2nd API calls when all contents are loaded (lazy loading) from the first API call in React js

杀马特。学长 韩版系。学妹 提交于 2019-12-02 02:54:56
I have some .json files. I need to show all the data from the first .json file in browser as lazy loading.I need to make API call to the second .json when all contents are loaded from the first .json file (when user scoll to end of the page) . I should not make all API call at a time. How to do this using react js. Make use of javascript scroll eventListener and calculate the window scroll height in order to trigger the async call. Please bind the necessary method in the constructor and define state respectively. Here is the code componentDidMount(){ if(this.state.newData.length === 0){ window