« first day (3999 days earlier)      last day (932 days later) » 

1:58 AM
I don't understand, how alert(_) works here. please help me.
 
@DamodaraSahu Please don't post unformatted code - use the up arrow to edit your post, then hit Ctrl + K to format the code in that post. See the faq. You have 25 seconds to edit and format your message properly before it will be removed. Please separate code blocks from your actual question. Put your question in 1 message and then your code in a 2nd and format it.
For posting large code blocks, use a paste site like like gist.github.com, hastebin.com, pastie.org or a demo site like jsbin.com
1 message moved to Trash can
@DamodaraSahu Please don't post unformatted code - use the up arrow to edit your post, then hit Ctrl + K to format the code in that post. See the faq. You have 25 seconds to edit and format your message properly before it will be removed. Please separate code blocks from your actual question. Put your question in 1 message and then your code in a 2nd and format it.
For posting large code blocks, use a paste site like like gist.github.com, hastebin.com, pastie.org or a demo site like jsbin.com
1 message moved to Trash can
 
    function loadScript(src, callback) {
            let script = document.createElement('script');
            script.src = src;

            script.onload = () => callback(script);

            document.head.append(script);
        }

        loadScript('https://cdnjs.cloudflare.com/ajax/libs/lodash.js/3.2.0/lodash.js', script => {
            alert(`Cool, the script ${script.src} is loaded`);
            alert( _ ); // function declared in the loaded script
        });
 
 
6 hours later…
7:40 AM
Hi
 
@AmitSharma Welcome to the JavaScript chat! Please review the room rules. If you have a question, just post it, and if anyone's free and interested they'll help. If you want to report an abusive user or a problem in this room, visit our meta.
 
Hi
I need some help with node js
 
user4061275
8:29 AM
Hi
 
user4061275
0
Q: How to add the json in input field as a text and update in initial state?

RAJA GOPAL MHave the initial state as follows const [initialstate, setInitialState] = useState({ checked: false, command: 5, dev: "developer1", }); and have the default assignments like "object" = {} "array" = [] "boolean" = true "string" = "" "number" = 0 "default" = "" I have 1 input field, and the...

 
10:53 AM
how to get access on the s3 bucket image url in react native ?
anyone tried out this ?
 
11:25 AM
Am I correct in believing that importing ecmascript modules inside a commonjs module is really painful in nodejs?
Since you have to use dynamic/asynchronous import() and thus all code that would normally be exported is also dynamic?
 
12:05 PM
I have a js script that takes a screenshot of the webcam which I want to pass to my already created Python OpenCV functions for processing. How do I do this? Is there something more automatic than saving the image using js and then having to read it again using Python.

This is all running inside a Flask app fyi
 
@BlueTurtle Welcome to the JavaScript chat! Please review the room rules. If you have a question, just post it, and if anyone's free and interested they'll help. If you want to report an abusive user or a problem in this room, visit our meta.
 
12:15 PM
I'm trying to figure out if I need to improve my question or just wait (or if it's a problem that's just not solvable?)
 
1:01 PM
hey how can I use react hooks in a loop?
 
1:11 PM
you cannot
what is it that you want to do
 
1:35 PM
@paul23 thx for asking
I am actually trying to use this function of this library.. but it is a "useBla" hook function usedapp.readthedocs.io/en/latest/core.html#usecontractcall
but I need to call that method like 1000 times in a row.. how would I do this?
 
Well the idea is that you don't use loops but instead use something else to execute it at once.
Like in that library there exist the functions useContractCalls and useChainCalls
 
@paul23 so you mean I somehow collect my calls into an array and call it at once?
 
yes
But don't do that before the hook
use the parent object to collect the calls - or at least don't use conditionals/loops before the hook
 
hmmm
because the hook will be fired (maybe) before the loop is finished?
 
no, it's the way react works (and the combination of ast/jit)
It needs to have the hook always at the "same place" and "same order"
 
1:45 PM
but I could have in the end of the loop an boolean set isLoopFinished to true; and use useEffect to listen to that and than fire the contractcalls hook?
 
An conditional would mean that sometimes code A is executed before the hook and sometimes code B - so a difference there and registering of hte hook fails.
similarly for a loop - a different amount of loops/statements might occur before the hook causing react to fail recognizing that the hook is actually a hook (and thus constantly rerendering)
So a good rule of the thumb is simply that there cannot be any branches in the component defined before hooks are defined in the component.
 
I really need to read this.. I don't get it -.-
 
no ifs/loops until all hooks are defined in a component.
 
why I am not allowed to loop and than "wait" till loop is finished and useEffect listen to that and than do the ook?
I thought useEffect is exactly for such a situation?
 
Simplified react counts the number of statements before a hook occurs to "register" a hook.
so with a loop each render there might be a different number of statements - causing the hook to fire again (defeating the purpose of a hook in the first place).
useEffect is used to notice that a (subset) of props (or states) has changed and act on those.
 
2:00 PM
@paul23 and what about when my useContractCalls should be called in Apps.js (and there is no parent of this?)
so I really need collect the calls in the parent in an array and pass it as props to the cild and do the useCallContracts() ?
 
I suggest just making a intermediate component
Or you could use a more functional approach and use array.map or similar
 
a wrapper arround my component (where the usecontractcalls is used) ?
array.map() isn't that also just another loop?
 
no, as it's not hte looping that's the problem but just the counting of statements, and map.array() is a single statement inside the current scope, and creates a new function scope in which it loops.
 
2:52 PM
o/
 
 
2 hours later…
4:51 PM
Can anyone access datatables.net ? I hard refreshed and it still doesn't load for me
 
5:12 PM
@paul23 thx I solved it.. as you mentioned there is this useCallContractS - But somehow I did not get, why array.map() is not the same like a for() loop hmm

solution for multiple calls was:
const result:any =  useContractCalls(
    myArrayOfCalls
  )
 
6:07 PM
Question about doing builds. I've been working all morning on modifying the project to allow for specifying multiple configuration builds. All of these configurations are unique folders within the src/assets folder. Examples: src/assets/alpha, src/assets/bravo, src/assets/charlie. Each folder contains its own unique config file, img folder and other stuff.

I just noticed something that I had overlooked. All of the other config folders are deployed with the build I specify. I can verify this by just loading a url for some img/filename.jpg file.
 
that, depends on your build process
it sounds like you have something that is likely just copying over a whole directory of assets
 
6:22 PM
i mean, again, that depends on your build process
there isn't just one build process that everyone uses
there's grunt gulp and webpack, and each can be configured uniquely for each project with plugins specific to each project
on their own, they don't do much
 
├── assets
│   ├── alpha
│   │   └── config
│   │   └── apple
│   │   ├── media
│   │   │   └── img
│   │   ├── settings
│   │   └── sources
│   ├── bravo
│   │   └── config
│   │   └── cookie
│   │   ├── media
│   │   │   └── img
│   │   ├── settings
│   │   └── sources
│   └── default
│   └── config
│    ├── steak
│    │   ├── media
│   │   │   └── img
│   │   ├── settings
│   │   └── sources
What I have is 1 codebase that I want to use as a template for multiple deployments with varying configurations, settings, img etc.
 
What is your build process?
 
@KevinB would the webpack you mentioned be what I should look into for handling this?
I just run the ng build
 
Ah angular,
 
npm run dev_alpha_build
npm run dev_bravo_build
Oh, sorry yes Angular 11
 
6:30 PM
i dont know anything about angular's build process, but it does have docs
if i can get them to load
 
Been randomly opening up various parts of the document but I'm not sure what to even look up.
 
> The application builder uses the webpack build tool, with default configuration options specified in the workspace configuration file (angular.json) or with a named alternative configuration.
does angular.json have entries for your various deployments?
i'd assume it has an entry that tells webpack to copy your assets folder to dist
 
It does allow for me to specify some differnet configs for the builds.
However, it does not have alternative src/assets for those areas that I can tell.
It looks like that src/assets folder is global so all builds get all items that are defined in the srs/assets config.\
I think I may have finally found something. It is called GLOB

https://codinglatte.com/posts/angular/working-with-assets-styles-and-scripts-in-angular/
 
i use a .js config rather than .json, which lets me add if conditionals etc, i could then take the build name and decide which folders to include/exclude
but i don't know how that relates to angular
 
Neither do I . We have someone who is a guru but he does not play well with others.
 
6:42 PM
you can apparently specify which configuration to use
which would allow you to specify a custom webpack.config.js and point at it
giving you more control
 
Appreciate your time Kevin. I have to run. I'll come back to this in the mornign.
 
that section is useful, but it doesn't let you specify different options for different builds, unless i'm missing something
 
7:06 PM
How do you typically pass environment variables from the build process down to your app? I've got .env.production, .env.staging files setup, and obviously in my build I can run npm run build --mode PRODUCTION and load the right file. However, I'm on a team with mostly backend focused devs who are insisting spinning up a .NET backend to pass the variables in which seems really dumb for a nodejs app to do it like this, though I also come from a .NET background.
It seems like we should just tell our docker container which environment it is and then pass that through to the app
 
7:33 PM
Anyone have a clue why if I download the CSS file as opposed to link it from a CDN, I can't load the icons?
 

« first day (3999 days earlier)      last day (932 days later) »