Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- async function fetchDishesAsync(
- setDishesContent,
- onDishClickHandler,
- setLoaded
- ) {
- return await axios(URL).then((res) => {
- products = res.data;
- setDishesContent(
- <FlatList
- keyExtractor={(item) => item.id.toString()}
- data={res.data}
- renderItem={({ item }) => (
- <Dish
- title={item.title}
- image={item.photo}
- content={item.short_description}
- price={item.price}
- onclickMore={onDishClickHandler}
- />
- )}
- />
- );
- setLoaded(true);
- });
- }
- //ВЫЗОВ
- console.log("LOADING...")
- useEffect(() => {
- fetchDishesAsync(setDishesContent, onDishClickHandler, setLoaded);
- }, []);
- console.log("LOADED")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement