« first day (3062 days earlier)      last day (1888 days later) » 
00:00 - 19:0019:00 - 00:00

7:00 PM
Quick question about React business: youtu.be/lWp-_5YnMCA
There is a link to plunker in the description: next.plnkr.co/edit/NdqNhaPVSa9Yp8Nq
 
Thanks so much, both of you! :)
@rlemon that post, amazing! :)
 
What I want to achieve - App.js - getting user - displaying user name in a nested component... If I start from homepage - it works fine - if I start from the route with nested component - FAIL. That's surely a no-brainer who anyone who has worked with React... That's why asking for quick help!
 
@MichalStefanow what error message are you getting?
 
There is no error message. It's the nested component that is not updating.
 
looks fine to me
you're saying, navigating to /passingprops/ directly by URL? I can't do that in the plnkr
 
7:08 PM
There is some trouble with Plnkr... Back in a day I could open standalone...
Now I'm getting some 500 and cannot do that... That's why workaround: edit some HTML and wait for livereload to kickin
 
use codesandbox.io
 
are you passing it as a prop?
 
@rlemon there's only one JS method I see in the link but the snippet no longer works — any other examples?
 
`<Route path="/passingprops/" render={()=><PassingProps user={this.state.user}/>} />`

In `App.js` http://next.plnkr.co/edit/NdqNhaPVSa9Yp8Nq?preview
 
7:13 PM
@WPZA do you need it to be in JS to get the problem?
 
@MichalStefanow uhh... you need to use the props directly
 
To be honest, I don't know any Java / Python — so I'd be reluctant to provide this to a client.
 
you can't just spread them into state when the component is created
 
you could have it in state (kind of like that) by using componentDidUpdate
 
7:14 PM
@DavidKamer if the component is re-rendered that shouldn't matter
(idk if it is or not, just saying)
 
@rlemon you mean if he wants to read it into state and then read it from there?
 
if the child triggers a re-render from the parent, the new state should be given just like the first render.
 
"you can't just spread them into state when the component is created" - I thought that it is the React thing: stackoverflow.com/questions/40063468/…
 
anyways. here is a working sandbox codesandbox.io/s/p9l159yo77
 
I've never seen it. obviously it's not working
 
7:16 PM
nvm.. it never fucking saved.
god that site sucks sometimes.
ohh it did
it's the cache. that's right.
 
the idea behind props is so your parent give the child info and keeps it update. There is no reason to put it in state
just do:
this.props.user.name
 
@rlemon are you sure it is working? The link to codesandbox is not working for me...
 
and don't spread the props into state...
 
no reason right now. it's a completely stateless component
 
7:17 PM
@MichalStefanow see my screenshot above.
 
@rlemon yeah, but I didn't want to get into the weeds of explaining stateless functional components
 
I see your screenshot above... I can arrive to such state on Plnkr too. Home page --> Passing Props. But if I start from Passing Props then it is failing :(
 
ohhh. okay. I misunderstood. directly accessing it. gotcha
 
I see... I will not save props to state. I will refer to "this.props.user.name" at all times
 
or just deref it
 
7:19 PM
what is the function that adds a property to every object in an array and the value depends on a condition?
 
like:
const {user} = this.props
in your render
@RachelDockter map with a ternary
 
i tried map it was saying undefinied
 
@MichalStefanow okay so it's back to the re-render issue.
 
Hi there! I've got an issue that i've been fighting against. My API streams a PDF file that I want the user to download through the click of a button (AngularJS in the front). So I tried everything here: stackoverflow.com/questions/…. Those approaches work for my CSV files, but not for the PDF. I get the PDF with all pages in blank. I know the PDF is healthy.
 
codesandbox.io/s/p9l159yo77 does this help (make note of the comments I've left in passing props)
 
7:20 PM
49
Q: how to download file using AngularJS and calling MVC API?

Edwin BeltranI am using AngularJS, and I have a MVC 4 API that returns a HttpResponseMessage with an attachment. var result = new MemoryStream(pdfStream, 0, pdfStream.Length) { Position = 0 }; var response = new HttpResponseMessage { StatusCode = HttpStatusCode.OK, Content = new StreamContent(...

 
@DavidKamer const formatted = original.map(me => clientId === id); its saying id is undefined
 
because there is no re-creation of the child, you don't get the updates as passed in the constructor. because it isn't called again.
 
but id is a property in the object
 
const newArray = array.map(item=>item.id==="blah"?{...item, newProp: "blah"} : item})
 
ok 1 sec
 
7:21 PM
@RachelDockter you have to do something like item.id
 
{...item}
this brings in the current object?
 
yeah, that spreads the current object into a new object, then you can set a new property in the same newly created object with the old object spread into it
@MichalStefanow you're making this way more complicated than it needs to be
 
no I was.
 
hmm its saying item is not defined :/
 
7:23 PM
I gave bad advice.
I'm probably on old React.
 
the reason why you would get it directly from props is because you want it to update whenever the parent updates it
 
componentWillReceiveProps is what you should listen for
 
@rlemon I thought that was "unsafe" or something now, but I'm likely wrong if you disagree
 
Not unsafe, but I think it was deprecated in 16
 
I just want to get basic stuff working...

I'm going to try https://reactjs.org/docs/context.html but first I want to understand basic concept of passing props and state...
 
7:24 PM
I had to learn all kinds of new lifecycle when I finally upgraded to 16
 
@DavidKamer idk. they changed a bunch of crap. I'm still on an early version of 16
or maybe 15
I started this project a year ago
  componentWillReceiveProps(props) {
    this.setState({ user: props.user });
  }
seems to do the trick
 
@MichalStefanow the idea is to pass props down so the child can use the parent's state. You don't want to have state differences between parent and child.
 
UNSAFE_componentWillReceiveProps() it's being deprecated...
 
then once you get all of this working, adopt mobx and create yourself a nice userStore.
 
or if you do, then you should just do it from the child component and leave the parent out of it if possible
 
7:26 PM
:D
 
But at least it works now...
 
Will lifecycle methods are deprecated, you'll need to use compenentDidReceiveProps instead
 
@rlemon you could use componentDidUpdate and check if the props have changed and set those props to state. That's what I was thinking.
 
I usually use componentDidUpdate when the props are updated
 
@DavidKamer ohhh. I recalled one was bad, so I thought that that was the bad one
I did suggest it first.
I should just shut up
 
7:29 PM
it's good. most of the stuff that changes are the things that probably shouldn't be used very often imo
 
Thank you for helping
I will try to implement similar solution with Context (new React thing)
First I wanted to understand what's going on
To be honest I still do not fully understand
 
immutability is the idea behind props
 
context isn't new. btw
 
basically you could have like 5 children, and you don't want each of the screwing up props passed down from the parent and fighting over the state... that's just one example, but the idea is that the child component is just receiving the props, not changing it. The child component can use a function passed via props to adjust props in the parent component if absolutely neccesary
 
Makes sense, children shoudln't mess with parent props.

But if the parent updates, child should update too.
 
7:33 PM
yep, that's the idea. And state is "immutable" but you change it by calling this.setState({})
so when the state in the parent updates, the props update for the children
you could also pass props down from props or whatever you need
 
@MichalStefanow the child does update, but the constructor may not be run
 
@SterlingArcher how's your love life doing?
 
because the child might not be recreated
 
@rlemon "context isn't new" - hashnode.com/post/… (that's an old post, that's why)
 
@ndugger good to see you man. It's starting back up. Been on a few dates with this girl.. I like her.
 
7:35 PM
so how ya gonna screw the pooch on this one?
 
I need to explicitly listen in "componentWillReceiveProps" OK... Not ideal but can do... It will suffice for now
 
I was dating some girl for like 2 months before I self sabotaged it to shit, but she basically pulled me up out of my dark slum, and made me get my shit together; I feel the most mentally healthy I've been in a long time
I'm gonna start getting back out there now too
 
@ndugger just catfish jordan. it'll be fun
 
I probably still have his number
Yup, I found it
Gotta send a meme; It's been too long
 
7:48 PM
@nd
@ndugger hey man, sorry if I bother you too much. I'm still with this PDF thing. Could you help?
 
We fixed our encoding issue by tweaking the server code; do you have access to that?
 
@ndugger I do. It's Laravel using dompdf
 
I don't know php well enough to be able to help you much; you might want to post in the php room to see if you can change some encoding on the server-side
 
@ndugger Alright, nice idea.
I just thought it was a JS issue since if I ping the URL directly (after removing the auth guard) I do get the PDF just fine.
 
oh, well then hold up
If you can see it by going to the URL directly, then the encoding is probably fine
Are you trying to display it to the user? Force a download? How are you doing it?
 
7:57 PM
@ndugger Force a download. I tried FileSaver and the generating link approach, like this: stackoverflow.com/a/27442914/678455
 
We're doing something very similar. Without pulling in a library though. How are you downloading the file? via fetch?
 
Yeah, a basic XHR
 
Can you show that code, and the code you use to shove the file in a blob before attempting to save it?
 
I just tried the library since I thought it would be more through with the encoding or have more options. No luck.
 
We use fetch, so it might be abit different from your XHR
but we can probably solve it
 
7:59 PM
with the library, it's this:
var blob = new this.Blob([data], {
type: strMimeType
});

this.FileSaver.saveAs(blob, fileName);
 
What is data?
 
@Mauro Please don't post unformatted code - hit Ctrl+K before sending, use up-arrow to edit messages, and see the faq.
 
also, what's the mime type you're passing in?
 
Before that, I just used (and variations of this):

      a.href = rawFile;
      a.target = '_blank';
      a.download = fileName;
      a.setAttribute('style', 'display:none;');
      D.body.appendChild(a);
      a.click();
      D.body.removeChild(a);
 
can't you just use URL.createObjectURL?
 
8:02 PM
Yes, which is why I decided not to pull in a library for that
 
@ndugger application/pdf
I also tried adding the encoding application/pdf;charset=utf-8
 
ok, mime type looks right; what's the data, and how do you get it? Show me the XHR and all that
 
I tried createObjectURL as well
 
Hi, got asked about this for a project. Does a software suite or ask exist that would convert scanned timesheets to excel?
 
OCR
 
8:03 PM
Yeah that's what I see online
Wonder how effective it is, would probably need to use a specific paper template to work with the software
 
We use ABBYY at work for OCR, but it's not flawless, that's for sure
 
I'm using restangular to get the data.
this.API
.one('cars', this.$state.params.carId+'.pdf')
.get()
.then((response) => {
this.downloadFile('car-' + this.car.id+ '.pdf', response, 'application/pdf;charset=utf-8');
})
 
@Mauro Please don't post unformatted code - hit Ctrl+K before sending, use up-arrow to edit messages, and see the faq.
 
They are talking about rolling their own application, but I said there must be some exisiting suite of software
 
What is this.API?
 
8:05 PM
@ndugger and how accurate do you find it?
 
OCR is hard to develop; you need a lot of training data too
It's accurate enough, but it sometimes misses things if people have bad handwriting, lol
which is to be expected
 
I remember doing some of that learning C# image recognition. was a very nice free course on how to write OCR.
it's.. complicated.
 
Yeah true so would it be technical to set up, or require a dev to administer it?
 
@ndugger this.APi is Restangular
 
Let me look that library up; never used it
 
8:07 PM
So here is the thing @ndugger. If I compare what I get through XHR with a curl request, I get pretty much the same except for some characters. Of course that's the issue.
 
@Mauro I'm gonna try to dig into the source a bit, but I bet you your problem exists because of that library
 
if you can ask for the resource on its own and it works....
obviously the server is sending proper stuff.
xhr/curl shouldn't matter unless someone or something is getting in there before you see it
 
@ndugger I'll give it a try with native http, do you think it's worth it?
 
I bet the Restangular library is trying to encode it as a string when it downloads it. You either need to configure it to resolve with a blob, or not use that library.
Use Fetch
it's super easy
I hate all of these libraries that try to emulate fetch, and do it poorly
I'm looking at you, axios
.withHttpConfig({responseType: 'blob'})
Found that in the issues for that library
try adding that
@Mauro
 
ok
Thanks man, I'll try it and be back
 
8:12 PM
@Mauro take a look at this too; someone else using that library to download a PDF github.com/mgonto/restangular/issues/479#issuecomment-220340885
 
Man, life saver
It worked
 
Yeah, naughty library... messing with the encoding
tisk tisk
 
I was looking at the problem from the wrong angle. That lib just worked every time before. And I'm using it for CSVs and images as well with no issues, so I just thought the issue was something else.
@ndugger, please keep my contact for anything in the future. I owe you one.
 
@ndugger SOOOOOOO many memes
 
I started vaping again, but it's CBD oil instead of nicotine
 
8:20 PM
@ndugger I'd gladly you roll you a nice one for this. Where you from?
 
@ndugger how's that workin for ya?
does vaping change the delivery like it does with THC?
my MIL is looking at using it for sleeping better. but just the oil drops
vaping might be a tastier approach
 
so i read the readme for standard jslint rules ... but it's in json right? github.com/standard/eslint-config-standard
 
the schema is a js object and also valid json
 
I prefer to use the CBD dropper I got that you put under your tongue, but vaping is still nice
I can;t tell if it's placebo yet, but I feel like it helps a good bit with my anxiety and ocd
 
user1596138
9:15 PM
@ndugger Does that give the same effect for you
 
user8729657
9:40 PM
Do I have to do RUN npm install in my docker file or is there another way around it?
 
@OvieAdese you can just copy the files over, but not the best way
you don't have to exclude node_modules, but should and run install
 
user8729657
No choice the package I want has a manual configuration which is causing errors when I go and build the docker image. @DavidKamer
 
user8729657
And what image should I be using for most of my applications
 
user8729657
?
 
user8729657
just node
 
9:52 PM
I use node alpine
but you could just use node if you wanted.
@OvieAdese you things are manual?
 
user8729657
I'm using sementic-ui, for front end and it has a manual install
 
You mean the package isn't installed in package.json?
What I'm getting at is: what steps do you take to "manually" install it?
 
user8729657
After you do npm install semantic-ui, it brings up command line options for you to go through and then install
 
user8729657
but you'll have to press enter/set your own setting
 
user8729657
then it installs
 
user8729657
9:59 PM
@DavidKamer
 
10:44 PM
as of now, roughly 10k of the downvotes i've cast were on posts that have since been deleted
145 of my upvotes were on now deleted posts
 
I wonder if you've cast more downvotes than anyone else on the network
it's not unlikely
 
i'd find that hard to believe
but it's possible
afaik that's not available in the sede
389 posts edited
235 helpful flags
30,926 votes cast
i should change my avatar to the downvote button
 
@OvieAdese sorry, stepped away. Let me check something
@OvieAdese Isn't there a way to specify the options in the package.json?
@OvieAdese shouldn't these settings be found in the semantic.json file?
 
11:36 PM
I love how darkgray is lighter than gray
Really just makes my job easier
 
Hey, does anyone know how I can get a list of methods of either a class instance or even the class itself?  I feel like this should be simple, but I'm stuck.  For instance:

class foo {
  doStuff () {
    return 'foo';
  }
}
let bar = new foo();
console.log(bar);
// []
console.log(foo);
//[]
I'm looking to get ['doStuff']
 
@Rooster Please don't post unformatted code - hit Ctrl+K before sending, use up-arrow to edit messages, and see the faq. For posting large code blocks, use a paste site like gist.github.com, hastebin.com, pastie.org or a demo site like jsbin.com
 
bar.doStuff
you could access the prototype
 
Looking to get the methods of unknown object
ah, that works
thanks
 
00:00 - 19:0019:00 - 00:00

« first day (3062 days earlier)      last day (1888 days later) »