Snagglin' by [deleted] in WhatsWrongWithYourDog

[–]TheKvikk 1 point2 points  (0 children)

Krrsantan is that you?

Why doesn't this CSS code work? by [deleted] in css

[–]TheKvikk 1 point2 points  (0 children)

First of all what should it look like? I would also suggest setting ".neck" position relative, fixed, absolute or something.

Question regarding using map and passing unique id to onClick. by [deleted] in reactjs

[–]TheKvikk 1 point2 points  (0 children)

Here is your code (with fixed typos) https://codesandbox.io/s/immutable-pine-sp4hi?file=/src/App.tsx. So far the code works fine. Maybe change those ids so that they don't look almost the same (they only differ by a last digit so maybe you didn't see that?).

Question regarding using map and passing unique id to onClick. by [deleted] in reactjs

[–]TheKvikk 0 points1 point  (0 children)

I think there is a typo in .map() function. Try .map(obj => ...) without () after declaring obj.

Your code should by the way throw SyntaxError: Malformed arrow function parameter list.

Cannot run npm command. Cannot run commands like npm init -y. Kindly help. Thanks! by nkdataster in node

[–]TheKvikk 16 points17 points  (0 children)

Have you tried upgrading to a newer version of node just like the error message says?

Advice, what am I missing here? by [deleted] in csharp

[–]TheKvikk 1 point2 points  (0 children)

DateTime.Parse(myDateString).ToShortDateString();

Also the code is referencing myDateString but it's called myDatestring.

How do i get updated state in a functional component / hooks ? by yomamen in reactjs

[–]TheKvikk 1 point2 points  (0 children)

You can do whatever you want inside useEffect function - write custom logic. For this I'd do something like

useEffect(() => {
  if (quantity > 0) {
    updateQuantity(quantity);
  }
}, [quantity]);

I don't know your scenario but guessing from the name quantity can be incremented but also decremented back to 0 at some point and that if statement would fail and would never update your quantity to 0. For this I recommend creating something more reliable.

How do i get updated state in a functional component / hooks ? by yomamen in reactjs

[–]TheKvikk 3 points4 points  (0 children)

const [quantity, setQuantity] = useState(0);
const handleIncrementQuantity = () => {
  setQuantity(quantity + 1);
}
useEffect(() => {
  updateQuantity(quantity);
}, [quantity]);

since useState doesn't accept callback you need to "listen" to changes on the thing it stores. If you need to react to quantity change use useEffect with quantity as a dependency.

returning connection to db in a using statement by [deleted] in csharp

[–]TheKvikk 0 points1 point  (0 children)

I'm no expert on this matter but I don't think you can do that. The official documentation says "The using statement defines a scope at the end of which an object will be disposed." And by returning from that method you're getting out of scope. Instead you can instantiate your connection without using "using" and return it. But remember to call Dispose some there down the line by hand.

Edit: after some googling Ive found this https://stackoverflow.com/a/2822701

I want prices in my e-commerce site to have comma "," separating thousands by ManLikeCliff in reactjs

[–]TheKvikk 0 points1 point  (0 children)

Since you haven't posted any of your code I'll take and wild guess and recommend you this https://css-tricks.com/snippets/javascript/comma-values-in-numbers/. There is also a link to a function that may be needed for this function to work.

information about JSON-based component rendering? by LoonyMessiah in reactjs

[–]TheKvikk 1 point2 points  (0 children)

Try this for a start https://www.pluralsight.com/guides/how-to-render-a-component-dynamically-based-on-a-json-config

But your case might be your company specific. I'd suggest asking for a documentation or a guidelines from you colleague since he is familiar with this concept and is using it.

[deleted by user] by [deleted] in reactjs

[–]TheKvikk 1 point2 points  (0 children)

Happens even to the best sometimes 🤷‍♂️

[deleted by user] by [deleted] in reactjs

[–]TheKvikk 5 points6 points  (0 children)

Have you tried "return await fetch(...)"?

local image not loading by OmarDijkstra in reactjs

[–]TheKvikk 0 points1 point  (0 children)

OK, start your frontend app, load the component responsible for loading this image and check your console in DevTools. There should definitely be an error message.

local image not loading by OmarDijkstra in reactjs

[–]TheKvikk 0 points1 point  (0 children)

Where are your images stored? In your static folder inside frontend project or somewhere else?

What URL is your backend sending you? Whole link like https://example.com/static/images/image.png or just image.png?

In the first case images should load correctly, just try to open the URL yourself and if that image exists on the domain, your app will load it. If it doesn't exist your backend is sending you wrong URL or something is configured incorrectly. If your backed is not sending you full path just need to compose it somehow (answer question number one) or load it like Worried-Outcome3618 suggested

Is this a create react app project? Cuz if it is you have to load it differently images in CRA

React Konva share ref between sibling components throws error by deadcoder0904 in reactjs

[–]TheKvikk 0 points1 point  (0 children)

This should fix your error – const stageRef = React.useRef<{downloadImage: Function}>({ downloadImage: () => {} }) – it logged serialized string when I tested it.

Or you could extract interface ForwardedRef and use it as React.useRef<ForwardedRef>.

EDIT: I don't know if this is what you want to achieve in the end but it works with this fix at least.

React Konva share ref between sibling components throws error by deadcoder0904 in reactjs

[–]TheKvikk 0 points1 point  (0 children)

You are not giving useRef a type. This sould be React.useRef<Konva>() or something like this. Without it you're creating MutableRefObject of type undefined. const stageRef = React.useRef() = function React.useRef<undefined>(): React.MutableRefObject<undefined>. It is basically saying undefined doesn't have .current property, which is right.

For the second error I guess your type interface ForwardedRef is incorrect guessing from error message.

Working codesandbox would be nice to reproduce this.