Draken ∆Toman
Draken ∆Toman
KPCKevin Powell - Community
Created by Draken ∆Toman on 8/18/2024 in #front-end
File upload bug
<DropdownMenuItem >               <label htmlFor="profile-picture" className="flex items-center gap-2 cursor-pointer">                 <FileUp strokeWidth={1} width={20} height={20}/>                 <span>profile</span>                 <input                   id="profile-picture"                   type="file"                   accept="image/*"                   className="hidden"                   onChange={changePfp}                 />               </label>             </DropdownMenuItem> functions that will trigger to change the profile picture of the user   function changePfp(e) {     let file = e.target.files[0];     uploadImage(file)   }   const uploadImage = (file) => {     const reader = new FileReader();     reader.readAsDataURL(file);       reader.onloadend = () => {       const base64data = reader.result;       socket.emit('edit-pfp', {image : base64data});     };   }; Whenever I clicked it is prompting the file to upload and when I set the file and upload it. It is not triggering the changepfp function. I am not understading why it is not working as expected. Could you please help me with it. Thank you.
2 replies
KPCKevin Powell - Community
Created by Draken ∆Toman on 12/7/2023 in #front-end
Double images
index.js
import logo from './logo.svg';
import './App.css';
import { useEffect, useState } from 'react';

function Card({ wallpaper }) {
const { urls: { small }, slug, id, alt_description, user: { username, profile_image: { medium } }, description } = wallpaper;

return (
<div className="card" key={id}>
<div className='card-container'>
<img src={small} className='image-url' alt={alt_description} />
<span className='owner-profile'>
<img src={medium} className='owner-profile-image' alt={`${username}'s profile`} />
<span className='owner-name'>{username}</span>
</span>
<div className='wallpaper-details'>
<span className='card-title'>{slug.replace(/-/g," ")}</span>
<small className='card-description'>{description}</small>
</div>
</div>
</div>
);
}

function App() {
const [wallpapersList, setWallpapersList] = useState([]);

useEffect( () => {

async function load () {
let fetchData = await fetch('https://api.unsplash.com/photos/?client_id=ACCESS_TOKEN')
let fetchedJSON = await fetchData.json()
setWallpapersList(prev => [...prev , ...fetchedJSON])
}
load();

}, []);

return (
<>
<h1>Wallpapers</h1>
<main>
{wallpapersList.map((wallpaper) => (
<Card key={wallpaper.id} wallpaper={wallpaper} />
))}
</main>
</>
);
}
export default App;
import logo from './logo.svg';
import './App.css';
import { useEffect, useState } from 'react';

function Card({ wallpaper }) {
const { urls: { small }, slug, id, alt_description, user: { username, profile_image: { medium } }, description } = wallpaper;

return (
<div className="card" key={id}>
<div className='card-container'>
<img src={small} className='image-url' alt={alt_description} />
<span className='owner-profile'>
<img src={medium} className='owner-profile-image' alt={`${username}'s profile`} />
<span className='owner-name'>{username}</span>
</span>
<div className='wallpaper-details'>
<span className='card-title'>{slug.replace(/-/g," ")}</span>
<small className='card-description'>{description}</small>
</div>
</div>
</div>
);
}

function App() {
const [wallpapersList, setWallpapersList] = useState([]);

useEffect( () => {

async function load () {
let fetchData = await fetch('https://api.unsplash.com/photos/?client_id=ACCESS_TOKEN')
let fetchedJSON = await fetchData.json()
setWallpapersList(prev => [...prev , ...fetchedJSON])
}
load();

}, []);

return (
<>
<h1>Wallpapers</h1>
<main>
{wallpapersList.map((wallpaper) => (
<Card key={wallpaper.id} wallpaper={wallpaper} />
))}
</main>
</>
);
}
export default App;
When the site loads I have to get 10 images instead getting 20 images Another 10 images are same as the first 10 images
1 replies
KPCKevin Powell - Community
Created by Draken ∆Toman on 3/5/2023 in #front-end
CSS doubt
3 replies