Relative Content

Tag Archive for javascriptreactjsvite

why is my logic to conditionally rendering a loading screen not working?

const [isLoading, setIsLoading] = useState(false); //this is the whole method where I want to use it const joinRoom = () => { const roomKey = roomKeyInput.current.value; if(roomKey == null) return let req = { sessionId: sessionId, socketId: socket.id } setIsLoading(true) axios.post(`${hostName}/join-room/${roomKey}`, req) .then((res)=>{ if(res.data.success){ setIsRoomAdmin(false) setRoomKey(res.data.roomKey) setConnectedToRoom(true); socket.emit(‘connect-to-room’, { roomKey: roomKey }) } }).catch(function (error) […]

How can I resolve the white screen issue during video transitions in React?

I have a loop of MP4 videos in my React application. However, when I click a button, I want another MP4 video to start playing. But as soon as I click the button, there’s a momentary white screen for about 1 second before the other video starts playing. How can I prevent this white screen from appearing?

onClick event only fires when double clicked for some components

I’m working on building an Instagram-like story section, and I’ve opted for an event-driven approach, which I’ve named ‘Intercomponent Communication.’ This could also be achieved using the MessagePort API. So far, there haven’t been any issues with other buttons like Next and Previous. However, I’ve encountered a problem with the PlayPause (Toggle) component. It emits the event only after I click twice in some components (When images change), but there’s no issue when I set up two separate events for the PlayPause component, such as onClick and onDoubleClick. I suspect the problem arises due to conditional event emission. One notable difference with the PlayPause (Toggle) button compared to the others is its conditional event emission. I’m happy to provide further clarification if needed. Thanks <3

Problem with proxy in my vite + react.js app

I have a simple application in react.js + vite. I have the api set up on “http://localhost:5000”, and the vite app on “http://localhost:5173”.
The proxy in vite is ignored and I don’t know how to fix it.

I’m working on the shopping cart but I can’t add it yet

enter image description hereenter image description hereenter image description here
Hello
I’m working on adding to cart
The image below is the code I use to add a shopping cart
Please help me see why when I click + to add to cart, all the products are + at the same time
and the product cannot be added to the cart
When I log out, it doesn’t show an object but undefined