|
I feel very very stupid right now. I'm trying to get a number field to display its values as "n,nnn" instead of "nnnn", but failing. Right now, we're using React+Redux to format incoming string value inputs via toLocaleString, but even with a pattern that allows for commas in numbers I'm still getting this error message:code:
What am I doing wrong? What do I need to do to get number inputs to accept/show numbers with commas, formatted as in toLocaleString?
|
# ? Jun 12, 2017 17:30 |
|
|
# ? Jun 9, 2024 16:33 |
|
Pollyanna posted:I feel very very stupid right now. I'm trying to get a number field to display its values as "n,nnn" instead of "nnnn", but failing. Right now, we're using React+Redux to format incoming string value inputs via toLocaleString, but even with a pattern that allows for commas in numbers I'm still getting this error message: Does this help? https://stackoverflow.com/questions/5917082/regular-expression-to-match-numbers-with-or-without-commas-and-decimals-in-text
|
# ? Jun 12, 2017 17:48 |
|
Skandranon posted:Does this help? Not exactly. Upon digging, that error message is a React error message. This to be a limitation with React/Redux where it imposes that big ol' regex on the value of a number field, and it seems like React just plainly doesn't allow for commas or something. At least, I can't find where that big ol' regex is set - and trying to manually set it on the fields doesn't work. Unfortunately our React/Redux lead is out on vacation this week, the week we deploy the new version (read: scramble to try and get it in before Wed). It may simply not be possible with our current setup.
|
# ? Jun 12, 2017 18:20 |
|
Pollyanna posted:Not exactly. Upon digging, that error message is a React error message. This to be a limitation with React/Redux where it imposes that big ol' regex on the value of a number field, and it seems like React just plainly doesn't allow for commas or something. At least, I can't find where that big ol' regex is set - and trying to manually set it on the fields doesn't work. I'm not a React guy but I was able to google up a couple of react plugins for formatting numbers. https://github.com/s-yadav/react-number-format maybe that?
|
# ? Jun 12, 2017 18:31 |
|
HaB posted:I'm not a React guy but I was able to google up a couple of react plugins for formatting numbers. Would have to run it by our team lead and get buy-in to bring it in. I just told our PM that we can't solve this right now and will have to push it to another sprint.
|
# ? Jun 12, 2017 18:36 |
|
Pollyanna posted:Would have to run it by our team lead and get buy-in to bring it in. I just told our PM that we can't solve this right now and will have to push it to another sprint. Time to rewrite everything in Vue.js while your team lead is gone. Go out in a blaze of glory!
|
# ? Jun 12, 2017 18:37 |
|
Skandranon posted:Time to rewrite everything in Vue.js while your team lead is gone. Go out in a blaze of glory! No thanks, I've had enough JavaScript adventures for a lifetime.
|
# ? Jun 12, 2017 18:46 |
|
Pollyanna posted:No thanks, I've had enough JavaScript adventures for a lifetime. The only way to transcend your suffering is to accept it willingly. Learn to love the Sisyphean nightmare.
|
# ? Jun 12, 2017 19:05 |
|
Pollyanna posted:Not exactly. Upon digging, that error message is a React error message. This to be a limitation with React/Redux where it imposes that big ol' regex on the value of a number field, and it seems like React just plainly doesn't allow for commas or something. At least, I can't find where that big ol' regex is set - and trying to manually set it on the fields doesn't work. What version of React are you guys using? edit: I grep -F'ed the entire react git history for that regex and its nowhere to be found. It's possible that it's concatenated from smaller strings or whatever. edit2: "The value must match to the following regular expression" is not in the react repo working tree. Waiting for git to search the whole history now. It takes a long time! edit3: That phrase isn't in the React git history either... Thermopyle fucked around with this message at 20:15 on Jun 12, 2017 |
# ? Jun 12, 2017 19:13 |
|
Thermopyle posted:What version of React are you guys using? My guess is they are using <input type=number" /> then they are manipulating the value via React into a formatted string in there and the *browser* is complaining. But I'm just an idiot, so I'm probably wrong.
|
# ? Jun 12, 2017 21:24 |
|
Skandranon posted:The only way to transcend your suffering is to accept it willingly. Learn to love the Sisyphean nightmare. Lumpy posted:But I'm just an idiot, so I'm probably wrong. Lumpy knows the ropes. Has anyone here used lerna to manage a js (actually TS / TSX / ReactXP in this case) project before? I decided to give it a go as part of a reorganization of an existing code base and I suspect that I've just wandered down one of those paths where I can expect to put 30 hours into tinkering with tooling before I get back to working on the project itself. If you DO happen to know how lerna works, or know npm well enough to groc it at a glance, feel free to take a stab at this unanswered stackoverflow question of mine. Also, stackoverflow is so lovely compared to how it used to be. I've put up a few effort-questions in the past couple of weeks that, years ago, would have had a handful of votes and at least a reply or two.
|
# ? Jun 13, 2017 00:37 |
|
Thermopyle posted:What version of React are you guys using? Yup, I'm actually a jackhole, who knew? It's not React. It's likely to be what Lumpy said: Lumpy posted:My guess is they are using <input type=number" /> then they are manipulating the value via React into a formatted string in there and the *browser* is complaining. But I'm just an idiot, so I'm probably wrong. So it really probably is my own stupidity. I really wish design would just let us use number fields with no commas
|
# ? Jun 13, 2017 13:34 |
|
Newf posted:
People want to gain rep fast, so they just refresh looking for easy to answer simple questions. If typing a response takes three minutes, somebody might type one up in two minutes fifty seconds and beat you so why bother.
|
# ? Jun 13, 2017 14:55 |
|
Lumpy posted:People want to gain rep fast, so they just refresh looking for easy to answer simple questions. If typing a response takes three minutes, somebody might type one up in two minutes fifty seconds and beat you so why bother. Yep, effort questions are rarely answered in my experience, usually by maintainers when they are too.
|
# ? Jun 13, 2017 15:07 |
|
Is there a good way to identify effort questions? I kind of like answering them when I get bored enough to want to - often they're too specialized into something I don't know at all. Sometimes I look over the bounty questions, but they seem to overwhelmingly have that specialization problem.
|
# ? Jun 13, 2017 15:44 |
|
Lumpy posted:People want to gain rep fast, so they just refresh looking for easy to answer simple questions. If typing a response takes three minutes, somebody might type one up in two minutes fifty seconds and beat you so why bother. I've never seen the point of posting a question to StackOverflow... I've always been able to find answers for what I want from other people's questions, or my situation is non-trivial enough that there isn't already an answer, and I'll usually figure it out myself sooner than I would get an answer from someone else.
|
# ? Jun 13, 2017 16:38 |
|
Skandranon posted:I've never seen the point of posting a question to StackOverflow... I've always been able to find answers for what I want from other people's questions, or my situation is non-trivial enough that there isn't already an answer, and I'll usually figure it out myself sooner than I would get an answer from someone else. I think you are forgetting that most people are lazy and in some cases, not very smart as well.
|
# ? Jun 13, 2017 16:50 |
|
I've had a few effort questions answered on SO, but that's overwhelmingly not the case. I try to answer effort questions though. I subscribe to the RSS feeds for the tags I'm able to help on and maybe a couple times a month I write an effort response. My highest rated question by far is one I asked not long after SO came out. It's an embarrassingly newbish question.
|
# ? Jun 13, 2017 17:56 |
|
What kinds of tests would you want to see for a simple open source React Component? I wrote a small wrapper for an existing JS carousel plugin, should I just be testing whether the props get forwarded as options to the plugin?
|
# ? Jun 13, 2017 19:24 |
|
No need to test the component you are wrapping, test that the wrapped component is rendered and receives the props you expect it to. Then test whatever else your wrapper is supposed to do.
|
# ? Jun 13, 2017 19:27 |
|
Historians will point at javascript has the cause of the downfall of our civilization. Js is a inflatable castle for kids, that people is using as permanent housing. Js is a army swish knife redesigned medical use. Js is a library full of necronomicons, and a book with a list of books that dont have their own title inside. Js is a mexican standoff between hardcore members of the sgml commite that refuse to go home after the 1986 florida convention. Js is simple, but required the creation of the galactic empire and 54 civil wars. Js is 2 + 2 = 2.0000000003 Edit: Forgot to add the question. When people talk about "Virtual DOM in the server" what they mean exactly? Do they have a object in memory in the server, with the same structure the whole DOM or what? Tei fucked around with this message at 10:55 on Jun 14, 2017 |
# ? Jun 14, 2017 10:39 |
|
yeah, but TypeScript is a good language it lets me write really, really terse code that makes it impossible for anyone else to quickly understand. but man, look at all these cool exciting new features i'm using! implicit returns for days!
|
# ? Jun 14, 2017 10:51 |
|
Plavski posted:yeah, but TypeScript is a good language As soon the mayor browsers support web bytecode, I think many people will jump to something like that. I see some downsides. Is nice to have everyone on the same language. And some people is going to decompile webbytecode into js, then continue there. So some websites in 2024 will be a big unholy main.js file. Tei fucked around with this message at 11:40 on Jun 14, 2017 |
# ? Jun 14, 2017 11:02 |
|
Plavski posted:yeah, but TypeScript is a good language Just because you can doesn't mean you should. Readability > *everything else*
|
# ? Jun 14, 2017 12:21 |
|
Plavski posted:but man, look at all these cool exciting new features i'm using! implicit returns for days! Babel.
|
# ? Jun 14, 2017 13:26 |
|
Pollyanna posted:Babel. if i want to await a Promise.all that async maps over ajax requests, it's really nice to be able to do it in a single, incredibly confusing line whenever i read guides to advanced typescript/es2017 features it takes me an hour just to unpick the terseness. christ it's almost embarassing how long it took me to get generators - not only is that syntax funky as all hell, but when examples are trying to wedge it all on one line cos implicit returns are the sexiness du jour, it's doubly annoying nothing makes me feel stupider than reading an example when words like return, if, else, and curly braces have just been dropped in favour of implicits and ternaries
|
# ? Jun 14, 2017 13:34 |
|
Of all the things to complain about Implicit return arrow functions is a weird one. I mean, maybe the first time you see it you might not know what it is, but then after that, what's to worry about.
|
# ? Jun 14, 2017 13:41 |
|
Generators in JS are meh and are a stepping stone to the amazingness that is async/await. I'd wait until async/await catches more traction before ditching promises. Look at a library like Koa to see an example of how libraries are following these cutting edge features and not stabilizing appropriately to the detriment of gaining acceptance. Implicit returns and ternary operators are cool and good. If you see them in a code review being abused to the point its hard to understand the code, spit on them and tell them to stop being an expert beginner. () => isValid ? ({a: 1}) : ({a: 2}); Is way easier to read/write than: function() { if (isValid) { return {a: 1}; }. else { return {a: 2}; } } Just because you can do something like this https://aphyr.com/posts/341-hexing-the-technical-interview doesn't mean you should. Pragmatism is a skill many developers lack.
|
# ? Jun 14, 2017 15:04 |
|
10+ years ago when I was a young and stupid Ruby developer my goal was always to write the sickest one-liners I could, with no regard for character limits. God I was a dumbass.
|
# ? Jun 14, 2017 15:09 |
|
Terseness is not a valid criticism of a language or language feature. A language should be as terse as is readable and no more. It's just as bad for it to be too verbose. Any feature that enables terseness or verboseness can be abused to harm readability. Readability does not mean "able to understand what this does the first time I ever encounter the language construct".
|
# ? Jun 14, 2017 15:37 |
|
Thermopyle posted:Terseness is not a valid criticism of a language or language feature. I completely agree with this dude.
|
# ? Jun 14, 2017 18:08 |
|
Yeah but the Javascript community has gone nuts. I think JS is the best language there is, there I said it. I haven't tried all of them, but the feature set, how fast it is, and how widely utilisable a .js file is across platforms and devices cannot be ignored. There are a million ways to compile things into JS if you don't like using ES2015+, but even if you do, it's really really good. Where things go wrong is within the community. When it started it made sense because JS was terrible, so there were a million libraries that made JS unrecognisable. Now, when I look at a pile of new fangled library, framework, and obfuscation infused JS code my eyes roll into the back of my head. You don't need all that crap. The language does everything you need out of the box. Stop re-inventing the language and use the language, internet. Stop introducing libraries that enable you to write incredibly confusing, slow, "functional only" crap. Stop trying to warp it, it's great the way it has become. I'm so thankful the dark lords who introduce new language features ignore 99% of it.
|
# ? Jun 14, 2017 19:44 |
|
Nolgthorn posted:Yeah but the Javascript community has gone nuts. I think JS is the best language there is, there I said it. I haven't tried all of them, but the feature set, how fast it is, and how widely utilisable a .js file is across platforms and devices cannot be ignored. There are a million ways to compile things into JS if you don't like using ES2015+, but even if you do, it's really really good. While I have come to appreciate JS more than I once did, it does not do everything you need out of the box. For example, it has a terrible default string manipulation library, which is how we ended up with the padLeft() catastrophe. This is one of the places I think C# really shines, it's included libraries are much better that most.
|
# ? Jun 14, 2017 19:57 |
|
Nolgthorn posted:Yeah but the Javascript community has gone nuts. I think JS is the best language there is, there I said it. I haven't tried all of them, but the feature set, how fast it is, and how widely utilisable a .js file is across platforms and devices cannot be ignored. There are a million ways to compile things into JS if you don't like using ES2015+, but even if you do, it's really really good. This post ties me in knots because I strongly agree with it and strongly disagree with it. Like, yeah there's too many developers chasing too many new things. On the other hand there's a ton of very useful libraries that you're just being a masochist or someone stuck in their ways for not using. And picking functional programming as an example of what you're on about is weird as functional programming is cool and good and has nothing to do with chasing new and shiny.
|
# ? Jun 14, 2017 20:15 |
|
Nolgthorn posted:Stop re-inventing the language and use the language, internet. Stop introducing libraries that enable you to write incredibly confusing, slow, "functional only" crap. Turns out programming runs on the same cycle as fashion.
|
# ? Jun 14, 2017 20:22 |
|
Thermopyle posted:This post ties me in knots because I strongly agree with it and strongly disagree with it. The problem isn't functional programming, functional programming changed my life in some small ways. But it is to be used in moderation, not for everything. Stuck in your ways, imo, is using a hundred libraries for everything regardless that they are new libraries. That is how JS has been done for a very long time and it simply is not needed anymore. It takes effort to learn how to write raw JS that doesn't require constant never ending fiddling to keep working.
|
# ? Jun 14, 2017 20:22 |
|
Maybe the reason theres 16000 files in the node_directory is because javascript lacks a good standard library. But I will not talk about this further, because JS has better minds than me, and I don't want to say something too stupid in public.
|
# ? Jun 14, 2017 20:24 |
|
Tei posted:Maybe the reason theres 16000 files in the node_directory is because javascript lacks a good standard library. node_modules inflation is more of an issue with npm than js. yarn does a lot to reduce that, from my understanding
|
# ? Jun 14, 2017 21:07 |
|
The Fool posted:node_modules inflation is more of an issue with npm than js. Even if you reduce it to 1000, it still says something about JavaScripts lack.
|
# ? Jun 14, 2017 21:29 |
|
|
# ? Jun 9, 2024 16:33 |
|
Thermopyle posted:This post ties me in knots because I strongly agree with it and strongly disagree with it. This is some wisdom right here, but I've also been more careful about about chastising people for not using libraries. The line between pragmatism and idealism is heavily blurred in JS. I got mocked for implementing one of Bluebird's functions from scratch in a module I made. When that module and some others were split out into proper npm modules used across all the web apps, mine worked fine, and everyone else came across bugs and build problems because of the modules that required Bluebird as a peer dependency and didn't manage/communicate that well. I unfortunately come across that type of situation far too frequently even with "ubiquitous" libraries like jQuery and lodash. There are a lot more libraries in use because the core language lacks a lot of useful things and Javascript developers are hyper-focused on nano-modularization. Yarn vs npm doesn't fix those issues. React Router is a pile of garbage that can't figure out how it wants to work if you look at the 2/3/4 versions. Express is an open source project that the creator sold for a few thousand dollars and went through some ridiculous ownership drama. Redux was based on one guy liking some functional aspects and claiming they were necessary without explaining why or how and leaving things like how to handle asynchronous dispatches up to the community, but it was still better than Flux and its creator who claimed that MVC doesn't scale. It's an entire community that flits from idea to idea, communicates lovely opinions in 140 characters or less, re-invents the wheel whenever possible, and never stops to think "how do we make this better". Somehow, it convinces people that these are admirable traits. Because of that, I'm burnt out on it. I'll probably still use Node for POCs and React for some webapp stuff, but I just can't do it anymore. I've started doing a lot more backend stuff and interviewing for fullstack or backend positions and it
|
# ? Jun 15, 2017 01:25 |