Relative Content

Tag Archive for javascriptreactjsvite

React app offline page render on browser reload

I have a React app https://codesandbox.io/p/sandbox/q6l8jp that uses the react-use-is-online npm package to check online and offline status. The package works perfectly, displaying appropriate messages for online and offline states. However, when I try to reload my browser while offline, my app fails to render and shows the browser’s default “no internet” page instead.

Serving static files in VIte React

I have a Vite React app and based on the domain, I want to serve assets statically of a particular folder.
I am going to use this same app for multiple partner and want to have different assets for different partner.
If the react app is being accessed from a.com then I want to serve all assets in src/partners/a and if the react app is being accessed from b.com then I want to serve all assets in src/partners/b.

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) […]