Each child in a list should have a unique "key" prop
// ..
{items.map((i) => (
<React.Fragment key={i.id}>
<Item {...i}/>
</React.Fragment>
))}
// ..
// ..
{items.map((i) => (
<Item key={i.id} {...i}/>
))}
// ..
Подскажите, как лучше организовать поиск сотрудников, если их больше 2000, делать один запрос к API и получать сразу всех из БД(mysql) и среди них искать нужного или каждый раз делать поиск конкретного пользователя?
const employees = [
{
"id": 1,
"name": "Leanne Graham",
"username": "Bret",
"email": "Sincere@april.biz",
"address": {
"street": "Kulas Light",
"suite": "Apt. 556",
"city": "Gwenborough",
"zipcode": "92998-3874",
"geo": {
"lat": "-37.3159",
"lng": "81.1496"
}
},
"phone": "1-770-736-8031 x56442",
"website": "hildegard.org",
"company": {
"name": "Romaguera-Crona",
"catchPhrase": "Multi-layered client-server neural-net",
"bs": "harness real-time e-markets"
}
},
{
"id": 2,
"name": "Ervin Howell",
"username": "Antonette",
"email": "Shanna@melissa.tv",
"address": {
"street": "Victor Plains",
"suite": "Suite 879",
"city": "Wisokyburgh",
"zipcode": "90566-7771",
"geo": {
"lat": "-43.9509",
"lng": "-34.4618"
}
},
"phone": "010-692-6593 x09125",
"website": "anastasia.net",
"company": {
"name": "Deckow-Crist",
"catchPhrase": "Proactive didactic contingency",
"bs": "synergize scalable supply-chains"
}
},
]
const employee = employees.find(emp => emp.id === 2);
Failed to execute 'atob' on 'Window': The string to be decoded contains characters outside of the Latin1 range
const d = (name, blob) => {
const url = URL.createObjectURL(blob);
// code
}
Добрый день всем подскажите пожалуйста готовый код на html и javascript или направление куда копать
Возможно есть какая-то библиотека...?
Подскажите, кто делал и может быть кто-то знает как сделать такой эффект при скролле страницы?
$('*')
Вы практически заюзали querySelesctorAll('*')
(из чистого JS) и тем самым повесили события на все дочерние элементы.// выбирайте не все элементы
$('*')
// а более конкретные
$('.item')
const elId = document.querySelector('#id');
const elsA = elId.querySelectorAll('a');
elsA.forEach((el) => el.remove());
<a class='1'>
In CSS1, a class name could start with a digit (".55ft"), unless it was a dimension (".55in"). In CSS2, such classes are parsed as unknown dimensions (to allow for future additions of new units) To make "2x" a valid class, CSS2 requires the first digit to be escaped ".\32x" [2x]
Пишу на React
const [imageUrls, setImageUrls] = useState([]);
async function readAsDataURL(image) {
return new Promise((resolve, reject) => {
const reader = new FileReader();
reader.onload = () => resolve(reader.result);
reader.onerror = reject;
reader.readAsDataURL(image);
});
}
useEffect(() => {
(async () => {
try {
const urlPromises = selectedImages.map(readAsDataURL);
const urls = await Promise.all(urlPromises);
setImageUrls(urls);
} catch (error) {
console.error(error);
}
})();
}, [selectedImages]);
return imageUrls.map((url, index) => <img src={url} alt="" key={`previewImage:${index}`} />);