I’m playing around with React Hooks and am facing a problem. It shows the wrong state when I’m trying to console log it using a button handled by event listener. CodeSandbox: https://codesandbox.io/s/lrxw1wr97m Click on ‘Add card’ button 2 times In first card, click on Button1 and see …
Tag: javascript
Why is my html, css, and javascript content shifting to the right on my phone (different platforms)?
Phone Content The image I have attached is a screenshot of how my webpage https://www.taniaswebpages.com looks. Everything is shifted to the right. When I work on this page in Brackets, my content is kind of centred but mostly towards the left, and the 2 trees are on the right side. I am doing a website chall…
How to use forEach method for objects in array in JavaScript?
Here is an array of donut objects. Directions: Use the forEach() method to loop over the array and print out the following donut summaries using console.log. I wrote this code but it doesn’t work : What’s wrong? Answer Instead of change it to You are looping through the donuts array and calling ea…
wait for asynchronous functions to finish in Angular
So I was working on a new component in Angular and in the ngOninit I have the following asynchronous functions below… This.getUserProfile needs to be finished before I can call this.getPrivateGroup() and this.getPrivateGroup() needs to be finished before I can call this.loadGroupPosts(). I know I could …
Parent element changing when javascript applies a transformation
I am trying to create a side menu navigation that slides into and off of the screen when you click a button. I have a container around the menu and the button so that they move together. The width of the container is 13% along with the menu which is weird that the menu is 13% of the body and
Getting URL Parameters on GatsbyJS
Is there a way to retrieve url parameters passed on pages of project built on GatsbyJS? I’m trying to implement a password reset function on my page using AWS, but they can only send the parameters through a link sent to the user’s email. So the flow would be like this : User triggers Forgot Passw…
CORS blocks mutation in GraphQL Yoga
I am working here with a graphql prisma backend and a graphql yoga express server on top of that. In the frontend, I am trying to call a signout mutation but its blocked by the CORS policy. Though I have added cors settings in my graphql yoga server, I keep getting this error. GraphQL Queries are working fine…
How to return based on actual arguments being sent?
Let’s say we have a function with two arguments. It’s being called many times with different arguments on every call. So, its impossible to stub it with withArgs option. I want to write a stub function which will check the actual arguments being passed (args1, args2) and return a static response w…
Length of Array of Objects in JavaScript
I understand that finding the length of a JS object has been answered extensively here With one of the suggested solutions being Object.keys(myObj).length However, I’m struggling to find out how can I find the length of all properties contained on an array of objects. ie: Object.keys(users).length //3 G…
how to store image / video file using gundb?
I know the traditional way is to store image/video file in one place and then just save the reference index into db’s table. Now I am learning about gundb, I can store key-value json type data very easily, but since it is decentralized, if I wanna make a say chatroom app, how should I handle image stori…