|
LifeLynx posted:
Arrow notation functions in JS keep the this context. As such, this will be defined as whatever it was in the render function, which probably isn't what you want. Directly pass the ClickHandler function (without parentheses) and you'll be fine code:
|
# ¿ May 6, 2019 16:29 |
|
|
# ¿ Apr 29, 2024 10:36 |
|
Another way to do it would be with a parameter-object but I guess in your case you couldn't prevent someone from calling your function with both a GUID and an ID.
|
# ¿ Mar 22, 2020 23:17 |
|
D34THROW posted:Hopefully the right place to ask this: It's plain old javascript with some jQuery in it. These code:
jQuery creates a function called $ in the global scope to make it easier to type. e: nowadays, people are using jQuery less and less, and you can pretty much replace this function with document.querySelectorAll("..."). However, do note that the jQuery $ function returns a jQuery object so you can chain calls. document.querySelectorAll does not. cutList is probably a self-calling anonymous function. Hard to say without the last few lines of it. Usually self-calling anonymous functions are used to not pollute the global scope with functions that don't need to be used elsewhere. The syntax is like this code:
go play outside Skyler fucked around with this message at 19:17 on Mar 23, 2020 |
# ¿ Mar 23, 2020 19:15 |
|
D34THROW posted:I didn't realize this rabbit hole went so deep I'm barely scratching the surface here, it took me an hour yesterday to figure out why Firefox was throwing an error on .valueOf(). This is indeed an associative array, also called just an "object". In JavaScript, you can declare new, complex tree objects using a JSON-like notation (it's not exactly the same but close enough for what you care about right now). An object in JavaScript can have functions, other objects. It's an associative array of whatever you want. Not exactly sure about my terminology here, maybe someone can chime in. I've been doing JS for so long that I'm basically not thinking about these things anymore. e: something I make EVERYONE who works in my team read is java script: The Good Parts. The book is relatively short and you can get it as an e-book for a fistful of dollars. Definitely read it if you want to avoid common pitfalls and write good code. Nowadays it's a bit dated in the solutions it offers, what with the new EcmaScript standards, but the gist of it is still very good. go play outside Skyler fucked around with this message at 19:46 on Mar 23, 2020 |
# ¿ Mar 23, 2020 19:42 |
|
That's weird. My only explanation here would be that you have some additional Express middleware that's causing this issue somewhere. From what I've seen on SO, try listing all your routes and check which middleware could be running and try taking them out one-by-one until it works. Here's apparently how you can list the routes (which should include middleware)code:
|
# ¿ May 8, 2020 09:56 |
|
Better to make it an npm package with 5 dependencies
|
# ¿ May 25, 2020 23:06 |
|
OtspIII posted:I'm very close to being done adding accounts to my website, but the one remaining step is pretty intimidating--making sure that I'm sending passwords securely from the client to the server. Right now in my dev environment I'm just sending username/password in the body of my POSTs, but that seems like something that should extremely never go live. I've found a few ways of handling things, but am having trouble understanding the context of a lot of what I'm finding. Can I get a sanity check on what's good practice from everyone? Unless I'm completely out of the loop, you should be fine with just SSL and I honestly don't see why you would need a load balancer for a single server setup. I know some sites hash the password field before sending it out but that has always seemed overkill to me. For SSL, just use Let's Encrypt. It can fetch a certificate for you automatically and renews them every 3 months. And did I mention it's free and supported by all major browsers without any security warning? If you really think you need DDoS protection, go with something like Cloudflare. It's super easy to set up though you should check if their free tier is enough for you. I don't think there's any security implications with using a password field outside a form, except maybe some obscure exploit I'm not aware about, but it's always good practice to wrap all your fields in forms. This enables default behavior that most people are used to (like enter key to submit, better tabbing between fields, better autocomplete, etc). Probably also better for accessibility. You can always just override the onSubmit event of your form, call e.preventDefault() and return false to make sure the browser doesn't navigate away from the page and that you keep the context.
|
# ¿ Feb 21, 2021 23:33 |
|
SirPablo posted:I'm having issues with CORS, mainly I don't understand it well. Is there really no way to just pull the content of a php script that loads in the browser window fine within a page's JS? Imagine that website.com/data.php returned the text "12345", is the no way to really capture that within a js function? Unless website.com explicitly allows it, then no, not anymore. If you own website.com, just add the Access-Control-Allow-Origin: * header to the response and you'll be fine. Another solution, if you really need to scrape something on a server you don't have control of, is to use a proxy server which does the requests for you. CORS is there to protect people from attacks like logging you in to Facebook from another website. Because your browser has your session information for all websites you visit, the w3c decided to limit the attack surface by blocking all cross-domain requests. This is actually a good thing. If you're just testing out something for yourself, you can also just disable web security in chrome by starting it with the --disable-web-security command line argument.
|
# ¿ Feb 23, 2021 08:34 |
|
MrMoo posted:Like a heathen I just symlink node_modules across projects to cut on disk space, that sounds like a terrible idea
|
# ¿ Mar 6, 2021 19:01 |
|
Just going to state the obvious in case it's been missed. If you're actually displaying tabular data, like a list or something, then you should just use plain old tables.
|
# ¿ Mar 9, 2021 15:16 |
|
Do you really need a plug-in for that? Never heard of vimejs, but if you roll your own player, you can completely hide controls, and just draw your own scrubber based on start and end time. Calculations to know the percentage of playback based on video.currentTime is trivial.
|
# ¿ Mar 16, 2021 18:51 |
|
fsif posted:Gotcha. Yeah, obviously you know your project better than I do so take what I say with whatever appropriate amount of salt. Not to derail, but I think what you experienced might be due to keyframes. Not sure you can just seek to any random position in the video like that, it might snap to h264 keyframes. Come to think about it, I'd also suggest generating the clips on the server-side!
|
# ¿ Mar 16, 2021 21:59 |
|
Comedy option: deliver video video an mjpeg stream
|
# ¿ Mar 17, 2021 11:40 |
|
roomforthetuna posted:Passing a callback down gives you a way to have the child call the parent, it doesn't give you a way to have the parent call the child. Why would you need to call a function on a child? Change its property, get it to redraw, let react handle DOM updates. If your components are complicated enough that you need to call methods on them, they are too complex and you should probably break them down. The only reason I see for calling a method on a child component is to mess with the DOM and that's not something you should be doing in react.
|
# ¿ Apr 6, 2021 14:05 |
|
I have never encountered a case where a child component's rendering size affected parent components in a way that couldn't be solved with good CSS rules. I could tell you to "lol learn CSS" but a more constructive suggestion I would have, would be to create a withLayoutUpdate() High-Order-Component, that adds a new "didDraw" callback property to every component using this. When your child component is finished rendering, call this callback and have your parent components listen on that event and redraw accordingly, I guess. Not sure of the specifics of how to implement that, but it seems like a way to do it. I understand this feels like a limitation to React and if I was in your case I'd be feeling like I'm just trying to find ways around React's architecture as well. But to me this is a small drawback in a sea of advantages the "framework" has, including but not limited to writing super simple layout code. Mind you, this is coming from a guy who spent years writing UI's in WinForms, jQuery, Cocoa (interface builder et. al) and WPF. I've seen it all, and I still cringe every time I look at the amount of loving boilerplate and complexity needed to do simple poo poo with WPF when I compare it to React. I still very much enjoy how React is extremely down-to-earth and simple to understand.
|
# ¿ Apr 6, 2021 15:37 |
|
I'm not sure an empty tag is valid syntax. If you need a container element that does nothing, use a <React.Container>
|
# ¿ Jan 13, 2022 08:16 |
|
SimonChris posted:https://reactjs.org/docs/fragments.html Wow, I think that's new. Guess that's what happens when you don't touch web dev for a year 🤷♂️
|
# ¿ Jan 13, 2022 09:02 |
|
fuf posted:why does everyone write functions like this now: if you put HandleChange in a callback context, "this" will refer to the callback context with version 2. With version 1, "this" will be implicitly captured and refer to whatever it was when the function was defined.
|
# ¿ Nov 15, 2022 17:44 |
|
Might not be a popular opinion but as someone who's done a lot of everything web, a lot of embedded, a lot of Java, Kotlin and Swift, I'll say this: in 2022 it doesn't really matter if you barely know how HTML and CSS work anymore. Nowadays there's so much poo poo going on between the code you write and what's delivered to the browser, you'll be using a build system that handles all that stuff for you. Unless you're supposed to be the one initiating the project and building it from scratch, I'd just start learning React, Vue or Angular + TypeScript and worry about the details later. React in my opinion is the best, least opinionated framework, but the most important is to learn whatever your company plans to be using. Because you're not going to be the one starting the project from scratch, are you? ...???
|
# ¿ Dec 29, 2022 22:33 |
|
CarrKnight posted:Right, thanks for comments. 100%, but start with something that does all the boilerplate for you like create-react-app. Enjoy the ease of development of doing npm start during development and learn about how to build a release version of your app with web pack and upload all that poo poo to a server.
|
# ¿ Dec 30, 2022 10:53 |
|
Nolgthorn posted:Wait till you do things the right way and figure out why they're also wrong. All solutions point back to vanilla js, so then you do that and realize why React is probably the right way. It's a never ending circle. Every time I try to start a project without react I end up with a million calls to document.createElement and sometimes I feel that all JS needs is a standardized simple template system.
|
# ¿ Jan 30, 2023 11:17 |
|
roomforthetuna posted:Man, if they'd made react *without* the state management system then there might be a framework that I don't hate and wish death upon. but that's just JSX, which was my point: it should be part of javascript, and i shouldn't need webpack to use it
|
# ¿ Jan 31, 2023 15:23 |
|
i went through the pain of getting an electron+ts+import app running and also had some problems with debug working but release failing. it took me a whole loving day of fiddling with webpack and i hope i never have to do it again
|
# ¿ Sep 25, 2023 06:50 |
|
|
# ¿ Apr 29, 2024 10:36 |
|
The Merkinman posted:So because a time zone isn't defined, it's using a time zone where September 11, 2001 was a Monday? OK No, it's because you are calling the function from a time zone where it was still monday september 10th in UTC time. As another poster said, don't use JS Date object to parse a date. It's better to use something like moment or whatever the new hotness is.
|
# ¿ Mar 19, 2024 19:56 |