October 22, 2024
Chicago 12, Melborne City, USA
javascript

Faced problem with collapsable button on react map() function

i’ve created multiple collapseable div useing map() function. but when i click one item to expand others also expands. same as collapse. any sollution? i tried this codes but it does not works with me. [`const handleBlogClick = () => { if (item.id !== item.id) { setOpen(!open); } };`] You need to sign in to

Read More
javascript

React useEffect goes in infinite loop while fetching data

I am trying to fetch some data inside my component using useEffect hook and it is going in infinite loop. I am using this react tutorial page and this race conditions page for reference. Here is my code. function AppNew () { const [matchData, setMatchData] = useState(null) const [matchesLoaded, setMatchesLoaded] = useState(false) useEffect(() => {

Read More
javascript

How to get the value from select tag in alpine.js

I have an xml file where i am iterating the object as dropdownData <select x-model="areaData" class="form-input w-full cursor-pointer" x-show="dropdownType==='Area'" x-on:change="selectArea($event.target.value)"> <template x-for="(item, index) in dropdownData" :key="index"> <option :value="item.dataid" x-text="item.displayname" class="workspace-data flex hover:bg-accent focus:bg-accent cursor-pointer gap-4 items-center border-t first:border-t-0"> </option> </template> </select> selectArea(areaItem) { console.log(areaItem, " <>? "); //item.dataid } When i am trying to print

Read More
javascript

After changing the length of a page, why do I have to pause for a split-second before auto-scrolling?

In response to user input, I clear the nodes in a container, then copy some other nodes in. This changes the length of the page. I wanted to scroll back to the top right after this, so added this: window.scrollTo({ top: 0, behavior: 'smooth' }); But it wasn’t working. It never scrolled back to the

Read More
javascript

How to save files to a directory using FileSystemDirectoryHandle?

I’m trying to look for some documentation on FileSystemDirectoryHandle and if it is possible to save files to the opened directory. I’ve been searching for a couple hours now, any help will be appreciated. -Alex I tried searching on google but I’ve only found base overviews of the api. And I’ve tried looking at the

Read More
javascript

Is there a way to create the package.json based on the code?

I just start to study javascript and vue and trying to build the example project todo-vue. But it seems that the modules in package.json are too old and always fail during the "npm install". Is there a way that the package.json file can be updated with the latest version or regenerated from the project code?

Read More
javascript

Calculate point coords relative to a rotated DIV

I have a rotated DIV within a non-rotated DIV and I’m trying to work out the cursor position on the outer DIV in relation to the rotated DIV. I guess I need the position as though the coordinate system has been rotated to match the angle of the rotated div. Following is an example of

Read More
javascript

Extruding a 2D PNG into a 3D Mesh in BabylonJS

In BabylonJS, I’m attempting to extrude a 2d png image to a 3d mesh, whilst I’ve considered obtaining the contours/outline of the image by extracting the alpha channel of the image and then using the results to create an extruded polygon. I’ve gone with a more straight forward method which merely seeks to stack multiple

Read More
javascript

chatgpt roasts computer science engineer

here’s my small roast by chatgpt, plz dont judge it, I’m a student asking gpt many question. Alright, Anchal, strap in—this roast is going to come in hot and honest, just like your dream of coding your way to San Francisco while struggling with palindrome questions. 😜 So you’re aiming for a software engineering job

Read More
javascript

How to fix 15: exec: node: not found in a NodeJS project with Typescript on Windows?

I’m new to Nodejs and Typescript and facing a problem on a Windows machine. I set up an empty project with a single index.ts just for testing. I’m also using nodemon. When I use tsc command to generate js files from ts, it works without any error and the files are built in the build

Read More