Open Side Menu Go to the Top
Register
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** ** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD **

12-30-2018 , 09:02 PM
Quote:
Originally Posted by well named
There should be some way to add a lifecycle hook so that you re-render when the property updates, but it's been a couple years since I used React and I don't recall the details (re: your original code)
One of the things I googled was "force rerender react" or some such, but didn't find anything that worked. There is something called "hooks" that I hear about on react podcasts, but podcasters say it's brand new and they aren't necessarily using it for production yet.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
12-30-2018 , 09:16 PM
Quote:
Originally Posted by goofyballer
Keeping format strings straight for every different language imaginable (C printf, Go, Python, etc) is such a pain in the ass, plus concatenation is elite
Most languages have some sprintf support - there's a sprintf library for javascript, and that's what I use. python supports sprintf syntax (with some additions) via the "%" operator. Keep it simple.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
12-30-2018 , 09:39 PM
Quote:
Originally Posted by RustyBrooks
Most languages have some sprintf support - there's a sprintf library for javascript, and that's what I use. python supports sprintf syntax (with some additions) via the "%" operator. Keep it simple.
Yeah it's not rocket science. Java has similar with String.format, although logging frameworks like sl4j use a slightly different syntax which is annoying.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
12-30-2018 , 09:53 PM
Quote:
Originally Posted by RustyBrooks
there's a sprintf library for javascript, and that's what I use.
whats wrong with template strings?
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
12-30-2018 , 10:01 PM
Quote:
Originally Posted by Grue
whats wrong with template strings?
They're fine. If all you do is javascript, go for it. I program in 3-4 languages on a daily basis, having one string formatting method that works in them all reduces mental load a lot. I'm already always tripping over the similar-but-not-the-same thing in python, javascript, C and go.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
12-30-2018 , 10:30 PM
Quote:
Originally Posted by RustyBrooks
They're fine. If all you do is javascript, go for it. I program in 3-4 languages on a daily basis, having one string formatting method that works in them all reduces mental load a lot. I'm already always tripping over the similar-but-not-the-same thing in python, javascript, C and go.
Haha my buddy is a python guy who has to write ruby frequently. It's amazing how many bugs this has caused
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
12-30-2018 , 10:44 PM
Quote:
Originally Posted by kerowo
There are lots of places that advertise remote positions but I don't know of any place that consolidates those companies into one list you could work through looking for opportunities. So the first remote job may be easy to find, but the next one could be troublesome.
There are sites like We Work Remotely that consolidate, but I've only ever browsed them so no idea about the quality of their listings.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
12-30-2018 , 10:58 PM
I am going to need to learn python. What are the advantages of it for something like AWS lambdas. What are the good and bad parts in general?
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
12-30-2018 , 11:00 PM
Quote:
Originally Posted by microbet
One of the things I googled was "force rerender react" or some such, but didn't find anything that worked. There is something called "hooks" that I hear about on react podcasts, but podcasters say it's brand new and they aren't necessarily using it for production yet.
Force rerender (and really anything with force in it) sounds like one of those things that if you have to use it, you probably aren't doing something right.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
12-30-2018 , 11:07 PM
Quote:
Originally Posted by suzzer99
Force rerender (and really anything with force in it) sounds like one of those things that if you have to use it, you probably aren't doing something right.
Prolly, but react should probably rerender automatically when the value of the props it takes changes.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
12-30-2018 , 11:31 PM
Quote:
Originally Posted by suzzer99
I am going to need to learn python. What are the advantages of it for something like AWS lambdas. What are the good and bad parts in general?
Python cold start times are the best. Aside from that, everyone loves python
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
12-31-2018 , 12:29 AM
Quote:
Originally Posted by suzzer99
I am going to need to learn python. What are the advantages of it for something like AWS lambdas. What are the good and bad parts in general?
It comes with a standard library that is pretty inclusive, so a typical project only needs to have a few external dependencies. I have a half dozen or so personal python projects and most of them only require installation of 5 or fewer external libraries. Compare this to every JS thing I've ever done, most of which have dozens to hundreds.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
12-31-2018 , 01:19 AM
Quote:
Originally Posted by microbet
Thanks. This fixed the problem.

I imagine when imageId becomes set when the fetch returns, react re-evaluates and re-renders "<Answers..>"?


Quote:
Originally Posted by microbet
One of the things I googled was "force rerender react" or some such, but didn't find anything that worked. There is something called "hooks" that I hear about on react podcasts, but podcasters say it's brand new and they aren't necessarily using it for production yet.
I think hooks are just designed to allow you to use state and some other react features without using a class.

There was always talk of stateless-functional-components getting optimized some point in the future to not be considered the same as react classes by react internally, I imagine hooks are a similar optimization.

Quote:
Originally Posted by suzzer99
Force rerender (and really anything with force in it) sounds like one of those things that if you have to use it, you probably aren't doing something right.
Quote:
Originally Posted by microbet
Prolly, but react should probably rerender automatically when the value of the props it takes changes.
There is a method in react to force a rerender, but like suzzer says it is gross and you shouldnt use it. At my last company large parts of our codebase used force rendering because the dev couldnt be bothered to figure out why the render cycle was not behaving as intended.

You can also use a PureComponent and the method shouldComponentUpdate if you are doing something that wont rerender accurately.

However, usually stuff like this is your <Answer/> component using componentWillMount or another lifecycle method that doesn't care about prop changes and just renders once.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
12-31-2018 , 01:55 AM
LL, what's the deal with your career path currently. Feel like we haven't heard much in a while. Where are you at now?
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
12-31-2018 , 02:18 AM
I'm currently at a startup of 150 people as a solution engineer where my role is essentially to be an engineer on the sales/biz dev side of the house helping with onboarding clients/doing custom stuff/ debugging stuff in real-time/ but also building stuff into the product that is strategically significant. I was recently given a skunkworks esque project to try and do something a bunch of our now very senior engineers had tried years ago and wrote off as too hard, and I've been successful and got it working.

Its unique because they want this role to be a true engineering role and you have to pass a standard modern engineering interview (which makes it near impossible to hire any of the sales engineers that apply).

What I like most is helping clients with website stacks in various things, my side project was a JS-like language and most of the code I'm writing now is backend python. I've written my first PHP as well

I took the job because I had the unique experience they need (that's actually quite rare I've found) and the company is doing so well if things work out it'll be the last place I need to work before starting my own stuff (at least that's the goal).
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
12-31-2018 , 02:44 AM
Wow awesome. Not only finding that role, but it being at a smaller startup with some upside seems like a rather ideal scenario.

I wonder how rare fits like that are. I have had pretty solid matching technical experience but not anything really beyond that
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
12-31-2018 , 03:18 AM
Quote:
Originally Posted by Larry Legend
However, usually stuff like this is your <Answer/> component using componentWillMount or another lifecycle method that doesn't care about prop changes and just renders once.
I'm sure the answer is "it depends" but where do you usually find yourself fetching data - componentDidMount?, componentWillMount?, the constructor?

Do you consider

Code:
{ this.state.imageid && <Answers imageID= ...}
the proper way to do this or was that just for testing what the issue was?
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
12-31-2018 , 04:33 AM
I usually fetch in componentDidMount and again in componentDidUpdate, if it's something that needs to refetch if it's properties change (my most common use case for this is probably detecting and handling a route change).

You can realistically put it in either although there are some fairly esoteric reasons to use Did instead of Will.

I don't use constructors, but I think the constructor and componentWillMount are going to get called at the same place in the component lifecycle.

Regarding rendering I usually do one of two things
1. have the initial state set to something that will render a blank component or something that indicates it's loading
2. check that the data is loaded (I use redux so I just have to check the state to see if the item I'm expecting is there) and return a dummy JSX doc to indicate loading.

I'm fairly inexperienced with React but I haven't had any trouble with the above really. Except that I don't think I like redux.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
12-31-2018 , 07:14 AM
Quote:
Originally Posted by microbet
Prolly, but react should probably rerender automatically when the value of the props it takes changes.
It will.

Chances are your <Answer /> component isn't using it's imageID prop directly, but instead on initialization it's setting some internal state to the value of that prop and then working off that state? In this case, the component does rerender, but the output doesn't change.

There's a few things you could do:

Look at <Answer /> and see if you can just use the props directly (could use Larry's && trick and/or ternaries if it throws errors with empty props)

Use getDerivedStateFromProps (or if your on a super old react version for some reason, componentWillReceiveProps) lifecycle method to handle updating the <Answer /> state depending on incoming props changes.

see: https://reactjs.org/blog/2018/06/07/...ved-state.html
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
12-31-2018 , 09:06 AM
Quote:
Originally Posted by suzzer99
I am going to need to learn python. What are the advantages of it for something like AWS lambdas. What are the good and bad parts in general?
The bad part is having to be stuck on older versions because libraries you need to use aren't updated. Hopefully you can start out on 3.6 or 3.7 and avoid this problem for a few years.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
12-31-2018 , 10:56 AM
Quote:
Originally Posted by suzzer99
I am going to need to learn python. What are the advantages of it for something like AWS lambdas. What are the good and bad parts in general?
Quote:
Originally Posted by PJo336
Python cold start times are the best. Aside from that, everyone loves python
Quote:
Originally Posted by RustyBrooks
It comes with a standard library that is pretty inclusive, so a typical project only needs to have a few external dependencies.
These: people like it, there's a wide ecosystem of stuff and usually the standard library is great so you don't need it. Some people can't get over whitespace mattering. And there's optional type hinting now if you want to get annoyed about that in multiple languages . I think the syntax is pretty intuitive in general which often makes it easy to start using.

Lambda: AWS lambda includes their SDK in the runtime so it's very possible to do things with standard library and boto only and keep the footprint extremely small.

From a cost perspective (memory/CPU required) Python seemed best or close to it but this is a few months ago now so I'm sure everything has changed. (I do think 2.7 was actually better than 3.6 at the time, but you should definitely use 3.6 or 3.7 here and for many projects I don't think even the language/runtime differences are important relative to developer productivity.)

Quote:
Originally Posted by maxtower
The bad part is having to be stuck on older versions because libraries you need to use aren't updated. Hopefully you can start out on 3.6 or 3.7 and avoid this problem for a few years.
This seems less troublesome today (compared with a few years ago) and should be a nonissue for new projects.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
12-31-2018 , 02:42 PM
componentWillReceiveProps is what I was trying to remember. I realize I phrased it poorly ("force a re-render")
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
12-31-2018 , 03:20 PM
Hey Suzzer, humblebundle has a 2019 Python bundle available:

https://www.humblebundle.com/books/p...s_tile_index_1
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
01-01-2019 , 02:25 PM
The whole whitespace mattering was a bit weird coming from JS, but at the end of the day whitespace and curly brackets are essentially the same thing.

After a while it's actually refreshing to have to write code an exact way, where in JS people will do all sorts of stuff for "readability" when expressions are short.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
01-01-2019 , 10:59 PM
Sure whitespace and curly brackets are the same thing. Unless you count closing.

Code:
          }
        });
      }
    ]
  });
}
vs.

nothing

All languages should be whitespace based imo. So clean, so pretty.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote

      
m