В моем проекте клонирования ресторана детали ресторана не переносятся внутрь компонента. Мой проект также использует CSS Tailwind, можно ли просто использовать его для настройки данных внутри компонента? Если он использует реакцию, как можно их деформировать внутри компонента?
пример изображения
import RestuarantCard, {withPromotedLabel} from "./RestuarantCard";
import { useEffect, useState } from "react";
import Shimmer from "./Shimmer";
import { Link } from "react-router-dom";
const Body = () =>{
const [listOfRestaurants, setListOfRestraunt] = useState([]);
// as soon as we call setListOfRestaurant the react will call the diff and update the UI
const [filteredRestuarant, setfilteredRestuarant] = useState([]);
const [searchText, setsearchText] = useState("");
const RestaurantCardPromoted = withPromotedLabel(RestuarantCard);
useEffect(() => { //react Hook
fetchData();
}, []);
const fetchData = async () =>
{
const data = await fetch(
"https://thingproxy.freeboard.io/fetch/https://www.swiggy.com/dapi/restaurants/list/v5?lat=12.9352403&lng=77.624532&is-seo-homepage-enabled=true&page_type=DESKTOP_WEB_LISTING"
);
const json = await data.json();
console.log(json);
/*const restaurants = json?.data?.cards[1]?.card?.card?.gridElements?.infoWithStyle?.restaurants || [];
setListOfRestraunt(restaurants); // Keep the full list here
setfilteredRestuarant(restaurants); */
setListOfRestraunt(json?.data?.cards[1]?.card?.card?.gridElements?.infoWithStyle?.restaurants);
setfilteredRestuarant(json?.data?.cards[1]?.card?.card?.gridElements?.infoWithStyle?.restaurants);
};
//conditional Rendering
if(listOfRestaurants.length === 0){
return ;
}
return(
{setsearchText(e.target.value);}}/>
{
console.log(searchText);
const filteredRestuarant = listOfRestaurants.filter((res) => res.info.name.toLowerCase().includes(searchText.toLowerCase()));
setfilteredRestuarant(filteredRestuarant);
}}>Search
{
const filteredList = listOfRestaurants.filter
((res) => res.info.avgRating > 4.3);
setListOfRestraunt(filteredList);
}} >Top Rated Restuarant
{ filteredRestuarant.map(restaurant => (
[*]{
restaurant.info.promoted ? () : ()
}
))//We have looped using map function, also each of item should have unique key(property)
//The resList is an array of objects, where each object contains a key info, and inside info, there is another key id. Therefore, to access the id field, you need to drill into the info object within each resList item
}
)
}
export default Body;
В моем проекте клонирования ресторана детали ресторана не переносятся внутрь компонента. Мой проект также использует CSS Tailwind, можно ли просто использовать его для настройки данных внутри компонента? Если он использует реакцию, как можно их деформировать внутри компонента? пример изображения [code]RestuarantCard.js[/code] [code]import { CDN_URL } from "../utils/constants";
) } } export default RestuarantCard; [/code] [code]Body.js[/code] [code] import RestuarantCard, {withPromotedLabel} from "./RestuarantCard"; import { useEffect, useState } from "react"; import Shimmer from "./Shimmer"; import { Link } from "react-router-dom";
const Body = () =>{ const [listOfRestaurants, setListOfRestraunt] = useState([]); // as soon as we call setListOfRestaurant the react will call the diff and update the UI const [filteredRestuarant, setfilteredRestuarant] = useState([]); const [searchText, setsearchText] = useState("");
))//We have looped using map function, also each of item should have unique key(property) //The resList is an array of objects, where each object contains a key info, and inside info, there is another key id. Therefore, to access the id field, you need to drill into the info object within each resList item }
) } export default Body;
[/code] [code]RestuarantMenu.js[/code] [code] import useRestaurantMenu from "../utils/useRestaurantMenu"; import Shimmer from "./Shimmer"; import { useParams } from "react-router-dom";
Я строю платформу SaaS для бронирования столов ресторанных столов с помощью Stripe Connect. Рестораны могут связать свои собственные учетные записи полосы, и я хочу взимать плату за неявку, если гость не появится. Первоначально я попытался создать...
У меня есть экран, на котором мне нужно отобразить заголовок и список элементов в виде карточки. Весь экран должен быть доступен для прокрутки (как показано на изображении ниже).
84WmQ.gif
Я знаю, как это сделать с помощью прокручиваемого...
Правильно ли и/или обертывать сопрограмму обычной функцией так, чтобы нормальную функцию можно было обрабатывать совместно с функцией co_await?
Вот минимальный пример того, что я означает, что оболочка просто используется для передачи входного...
Правильно ли и/или обертывать сопрограмму обычной функцией так, чтобы нормальную функцию можно было обрабатывать совместно с функцией co_await?
Вот минимальный пример того, что я означает, что оболочка просто используется для передачи входного...