SPArcheon - on strike

JavaScript

Topic: Anything JavaScript, ECMAScript including Node, React, ...
Dec 21, 2023 15:53
@KevinB Would be my guess too, but the fact that they added a version of setState that includes a callback parameter that gets called after the state is actually set made me a tad worried.
Dec 21, 2023 15:45
Maybe worth asking on the site
Dec 21, 2023 15:44
I hope this is a bit clearer now.
Dec 21, 2023 15:44
I don't get if it at least maintains an ordered stack of pending updates or not.
Dec 21, 2023 15:43
to me these means that you technically can end up with your state set to visibility:true since it could batch the updates in the wrong order
Dec 21, 2023 15:42
read this two links
Dec 21, 2023 15:38
@KevinB It is not!
Dec 21, 2023 15:37
searchData = () => {
  // Start the loader
  this.setState({
    visibility: true,
  });

  // Nothing done here

  // Stop the loader
  this.setState({
    visibility: false,
  });
};
Dec 21, 2023 15:36
@VLAZ if you are setting the same flag on the state the order does matter. In the correct order you will display the loader and then make it invisible. It the two assignments are performed in the wrong order then you hide an already hidden loader.. and then you make it visible forever. Forget the fact that the logic should "take enough time to let the previous .setState complete"
Dec 21, 2023 15:33
@KevinB yes, but this just because you assume the wait is long enough.
Dec 21, 2023 15:32
In the code above, what makes you sure that the visibility will be set true and then false instead of false and then true?
Dec 21, 2023 15:32
If the .setState operation is asynchronous as they claim, what does guarantee you that the two operations will be performed in that order?
Dec 21, 2023 15:31
Maybe I am missing something but...
Dec 21, 2023 15:30
ok worked this time
Dec 21, 2023 15:30
searchData = () => {
  // Start the loader
  this.setState({
    visibility: true,
  });

  //  ....Your logic goes here

  // Stop the loader
  this.setState({
    visibility: false,
  });
};
Dec 21, 2023 15:28
@KevinB not what I mean
Dec 21, 2023 15:24
@KevinB it can not. .setState does not return a promise, so there is no way for the caller code to even know the operation is delayed
Dec 21, 2023 15:22
but... isn't .setState... you know... asynchronous too?
Dec 21, 2023 15:21
2
A: How to set a loading state for react component while sorting and filtering data?

Raghvender KatariaIn your render method you can have one loader implemented like <Loader visible={this.state.visibility}> In your searchData method, you can set the visibility of this loader true in the first line and false in the last line like below searchData = () => { // Start the loader this.setState({ ...

Dec 21, 2023 15:21
Which brings us to this answer for example
Dec 21, 2023 15:20
So. Simple question: suppose you have an async api call and want to show a loading message during the call.
Most will tell you to "just set a state variable before and after the call, then do some conditional rendering based on that"
Dec 21, 2023 15:19
oh, volunteers.
Dec 21, 2023 15:04
Hello. Sorry to bother you folks. Anyone here familiar with React wanting to spare some time for a question? I saw some answers on the main site that seem quite wrong...
Feb 10, 2022 16:53
@iLuvLogix that would be a valid option.. if only I could be sure that this is really an issue and not just me missing something obvious.
Feb 10, 2022 16:35
That said, tried to ask here, we will see if anyone knows or has a workaround
Feb 10, 2022 16:34
@VLAZ yep, that is an option. Right now I am using a development vm that had some preconfigured settings so I wanted to alter as little as I can but I guess that if anything fails... VS Code it is.
Feb 10, 2022 15:20
@iLuvLogix for that specific question the problem similar but not the same. In that case, the original poster is trying to use that syntax in javascript. So that probably is related to the target ecmascript/javascript build version. Anyway, thanks for the suggestion, will continue to look if something comes up
Feb 10, 2022 15:11
Like I said, I am using the 3.8 typescript package yet the editor underlines any instance of the optional chaining operator as wrong syntax. The optional chain was introduced since version 3.7, so it should be supported in 3.8.
Feb 10, 2022 15:10
@iLuvLogix yep, that is what the documentation on this page says. My understanding is that if you specify an npm package, then intellisense should use that version... but apparently it is not working that way.
Feb 10, 2022 14:49
My understanding is that VS2022 does no longer use external SDK installation, and should just enforce whatever is provided, either by a nget package or a npm one (my case)
Feb 10, 2022 14:48
Anyone knows how VS 2022 picks the typescript version it uses for providing intellisense? I have Typescript 3.8 specified in the project pakage.config file, yet the editor does not recognize the optional chaining .? syntax added in ts 3.7. Obviously, the thing works at runtime.
Feb 10, 2022 14:47
Afternoon, don't know if this is appropriate here so please forgive me otherwise.
 

Trash can

Like the recycle bin, but trashier.
Dec 21, 2023 15:29
> searchData = () => {
// Start the loader
this.setState({
visibility: true,
});

// ....Your logic goes here

// Stop the loader
this.setState({
visibility: false,
});
};
Dec 15, 2022 18:48
<(?:"[^"]*"['"]*|'[^']*'['"]*|[^'">])+>
Sep 28, 2022 14:57
<(?:"[^"]*"['"]*|'[^']*'['"]*|[^'">])+>
Sep 28, 2022 14:57
try that again and then click the message you just posted, it should bring you to the explanation
Sep 28, 2022 14:57
should go on until you refresh or post something else
Sep 28, 2022 14:56
now... you know :P
Sep 28, 2022 14:56
please, try...
Sep 28, 2022 14:55
Since you mentioned that, can you please write "<(?:"[^"]*"['"]*|'[^']*'['"]*|[^'">])+>" as a new message, without the ""
Sep 28, 2022 14:55
hi.
Sep 28, 2022 14:54
mumble...
 

Sandbox

Where you can play with regular chat features (except flagging...
Dec 16, 2021 14:45
<(?:"[^"]*"['"]*|'[^']*'['"]*|[^'">])+>
Dec 16, 2021 14:44
<([a-z]+) [^/]?>
Dec 16, 2021 14:44
does this still work?
 

Winter Bash Starring Room - Stack Ove

A Stack Overflow chat server room for placing a star on users ...
Dec 15, 2021 14:29
we should probably also star multiple messages, could be both.
4
Dec 15, 2021 13:52
In the past, number of starred messages in chat WAS used as a trigger for some hats.
Dec 15, 2021 13:51
@PeterHaddad not sure. The whole idea is to check that possibility.