« first day (2257 days earlier)      last day (2705 days later) » 

9:00 PM
ideally: <Route additional={{ hideHeader: true }} path="home" component={LandingPageContainer} />
@BenjaminGruenbaum You're not though, you're creating a new component that wraps the one I actually want.
At the moment the router has no concept of a header, that lives in the App container component
 
so? composition.
but check out my link. I think that's what you want
 
I'd like to just pass something down to the App
 
@david so what?
@david set it on some state and check it in the App part.
 
@BenjaminGruenbaum how do I set it on the state?
that's what I'm trying to do, but react-router doesn't seem to give me that option
 
it does, if you look at that link
 
9:03 PM
!!star rating or thumb rating
 
@rlemon star rating
 
cough
 
@Luggage the named components? That's not quite state, but it's actually not a bad solution so thanks for linking
I might end up doing that instead
 
i linked it before you asked for 'by state'
 
Yeah, I thought you were saying it was state when you said "It does, if you look at that link"
 
9:06 PM
but yea.. the child could call a method on the parent to set it's state and set a header. or the parent can use ref={} and then look for a property
or lots of things.
or the parent would look for static properties on the child to know what secondary component to wire up.. another (non-standard) idea.
There are no limits to the ways in which you can abuse react.
 
Yep, but i'm trying to pick the least abusive way
 
Ben's composite component is also valid.
then the react-router named components might be it.
 
It is, but it's a pattern that isn't used anywhere else in the codebase and I'd rather not introduce it
 
except that give you no 'wiring' between the components, that I know if
but the parent can do that for you, i guess
The benefit of using a tool like react router is that you can use it's features when you need.
 
I don't really want them wired together, I just want the App container to have enough information to decide whether or not to set a prop on the header
 
9:10 PM
Hm.. I use a property on the child for that. e.g. a 'title' that the route's component give me, I put in the header.
 
ah well, this will work for now, i'm hardcoding paths in a place other than the router but it doesn't do anythign too crazy
I don't think the child shouldn't decide how the header is rendered though... the child should be able to be rendered even without a header
I guess just having a property doesn't actually create a dependency
but it still looks weird
 
yea. In my case, the child just exposes properties that the parent reads and passes to the header
the child doesn't know about the header directly.
 
That feels like it breaks the one way data flow thing ><
gyar
 
kinda.
 
named components comes so close to what i want :(
 
9:14 PM
is the secondary value a static value, or 'calculated' by the child?
 
I'll dump a minimal example
 
user2620028
when extending a class in javascript, the subclass can create its own methods correct? ( non overrides )
 
// this is NOT what I do, but a quick and dirty psuedo version
childComponentChanged(newChildComponent) {
    this.setState({ mountedChild: newChildComponent });
}
render() {
    <Header title={this.state.mountedChild.pageTitle || "untitled"} />
    <Child ref={childComponentChanged} />
}
an abuse that's related to the fact that I started as a knockout.js app and I don't do evrythign in a strictly react way.
in my case, the child may be a react component or even a knockout.js viewmodel. a mobx observable or a ko.observable. so.. my real code would be useless
 
<Route path="whatever" components={{hideHeader: true, page: LandingPageContainer}} />
render() {
    <Header hide={this.props.hideHeader} />
    {this.props.page || this.props.children}}
}
 
9:22 PM
can you do that? set a boolean as a 'component' in components?
seems hacky
 
I don't know.
Just a thought.
 
but yeah, that would be perfect
 
I guess not.. I think it tries to make elements for you..
 
well, apart from {this.props.page || this.props.children}
 
that part is solid. the other components comes in on another property when you use named components
or children when not
 
9:24 PM
it's not great though
would be better if you could do <Route path="whatever" components={{hideHeader: true}} component={LandingPageContainer} />
 
i think it'll try to React.createElement(true) and that wont' work
 
to keep it consistent
 
meh, that's the least hacky part.
having one of two property names is something you can reliably deal with.
 
man, I suck at sql
 
my hideHeader: true abuse is probably worse.
is it jsut the indexroute that hides the header?
 
9:27 PM
if it was <Route path="whatever" params={{hideHeader: true}} component={LandingPageContainer} /> I'd be happy
indexroute and home
 
so all cases of LandingPageContainer ?
 
both load the same component though
yep
although when more designs come through there might be other pages that do it too
 
class LandingPageContainer extends React.Component {
    static hideHeader = true;
}
//app
render() {
    let hideHeader = React.Children.only(this.props.children).type.hideHeader;
}
or $type.. I forget.
 
it's also not quite 'hideHeader', the header just gets removed from the layout and a z-index:1 put on it
but that's immaterial
Yeah, but that's still putting it on the child which i don't want to do
it should be the route that decides :(
at least in my mind
 
you want hacky solutions, I am your man.
but you have all these "rules".
 
9:29 PM
maybe there is a good reason why the router can't pass down arbitrary params to the container
ahah, yeah
it's a new project, so I kinda want to make it as clean as possible
so when I hand it off I don't get called every week by the maintainers
 
> ReferenceError: OptimizeFunctionOnNextCall is not defined
wtf
 
that needs weird command line flags to work right?
 
JS Array sort seems to want to compare two values from the same array. What if I have one array that I want to compare against a static value, and give points (let's say out of 10) for how close the array value is to the static? Obviously with the closest semblence elements being in the lowest indices.
 
@david ohh.. you can get a reference tot he route through props.route and use that..
 
@Luggage yeah, that's kinda what I'm doing
 
9:33 PM
put hideHeader={true} on the <Route> and console.log this.props.route to test
 
Long story short: My app takes a 404 URL, and is supposed to query a collection of good URLs and sort them based on how close they are to the 404 URL. The top 10 or 20 results will be shown.
 
wait
really?
 
@Vap0r yourArray.map(x => Math.abs(constant - x)) will give you an array of dinstances.
 
really.
 
HMMMMM
 
9:35 PM
@BenjaminGruenbaum perfect! I guess map is better in this instance!
 
Have fun
 
yea. the extra props are on this.props.route
i had a robogist project open to test with.
 
bah, it puts it on the parent route
 
in App..
 
wait no, the other way around, it DOESN't put it on the parent route
 
9:37 PM
oh? ohh..
 
@BenjaminGruenbaum that doesn't seem to allow sorting the elements of the array
Unless I'm missing something from MDN
 
<Route path="/" component={App} icanseethis={1}>
  <IndexRoute component={LandingPageContainer} buticantseethis={2} />
 
yea.. i was testing with my / route..
 
@BenjaminGruenbaum How does that philosophy hold up in teams with different specialties? Not everyone can be an expert on everything
 
doh.
 
9:38 PM
i can get it from this.props.routes[1] :P
sooo close :(
 
Last day of work for the year!
 
22:7  error  Expected a return value       consistent-return
22:7  error  Unnecessary return statement  no-useless-return
:|
 
I wanted to work out the phrase "undefined is not a function" into an answer, here's my attempt: stackoverflow.com/a/41251677/1348195
@monners yes, that's the idea, but a lot of teams just have mediocre people.
 
yea.. just .reduce() this.props.routes for those properties you want
that way a child route can overide
 
@corvid you need to return something, and it has to be of the same type as whatever else you're returning in that function
 
9:42 PM
@BenjaminGruenbaum Ah, I figured you were talking from the opposite position - Everyone is expected to be a superstar
 
@corvid what code gives that?
also, some eslint rules may be contradictory. You decide which rules you want.
 
export function getIssues() {
  return async dispatch => {
    dispatch({ type: REQUEST_ISSUES });
    try {
      const issues = await request('/repos/rails/rails/issues');
      dispatch({
        type: RECEIVE_ISSUES,
        payload: issues,
      });
      return issues;
    } catch (e) {
      dispatch({ type: ISSUE_ERROR, payload: e });
    }
  };
}
 
not sure why that would be a 'useless return'
 
if I put just a plain "return" after the catch, it complains, if I return [] it works though
 
right. no-useless-return doesn't like return;
or probably return undefined;
does it give BOTH or those errors at once?
 
9:45 PM
And typescript doesn't like you returning different types from a function
you've made a function that is supposed to return an array of issues, so it should ALWAYS return an array
even if something goes wrong
 
@monners in this industry everyone who's not shit is a superstar :D
 
it does. In the pasted example there is only a single return.
and most people are shit. It's just the nature of the business. most devs are new devs
 
@Luggage but if an error happens then it will return undefined, which is why it's complaining
 
ohh, in the catch..
 
yar
 
9:48 PM
wait, why does that return issues AND dispatch them? If this is a stupid question, I dont know redux
 
@david sure it does.
 
he needs to either have a return in the catch, or at the end of the function. and all the returns have to return the same type, so in this case they should all be arrays
@Luggage That's also a good question
 
You can return "string or number or a Cat instance" in TypeScript.
function foo() : number | string | Cat {}
 
@BenjaminGruenbaum sure, if you're manually specifying the types and not relying on inference. But this guy isn't
 
9:52 PM
he also appears to be gone....
 
he combat logged
 
@rlemon eels are so cute, we have some in a creek behind our house that we feed by hand
they're freshwater though
 
not as creepy looking as moray type things
 
!!s/eels/children/
 
9:53 PM
@BenjaminGruenbaum That didn't make much sense. Use the !!/help command to learn more.
@BenjaminGruenbaum @rlemon children are so cute, we have some in a creek behind our house that we feed by hand (source)
 
!!/help
 
@rlemon oh god it's a reverse looped gif
 
@Vap0r Information on interacting with me can be found at this page
 
man, lots of pedo vibes coming from @BenjaminGruenbaum today
 
@KendallFrey still a fun gif
 
9:55 PM
@Luggage version delayed -_-
 
Husky Jesus?
 
> Where in the World?

this is a secret hat
huh?
how'd I get that?
 
I have a collection of valid sites on my intranet, are there any sources of information on guessing what valid sites a user intended from a 404? The 404 in this case is most commonly triggered by outdated links (from an old SharePoint instance) and from typical misspellings
 
Any GraphQL friends here? I am confused as to where Relay was defined in facebook's official example
 
9:57 PM
> For participating on a site on December 21.
ahhhh
voting counts it seems
 
@rlemon something about voting
 
you get a different hat based on where you are in the world.
 
> Actively participate in a community during the winter solstice. For the purposes of this hat the winter solstice begins when the first timezone has locally started Dec 21st and then continues until all timezones have locally ended Dec 21st (10:00 UTC Dec 20 ⇒ 11:59:59 UTC Dec 22).[1]8n606.png
 
or, maybe what time of day it was when you interacted.
 
!!afk gym to get slim then dinner to get less thinner
 
9:58 PM
i love my hat
it's not even a hat
 
> You have not earned any hats, yet.
 
how is that possible
go cast a vote!
 
No
 
user2620028
someone who is using react and jsx
 
user2620028
i feel as though i am doing something stupid here
 
10:00 PM
i was just grinding for the snaphat
 
user2620028
i am trying to call a function on an instance of a class as a bound function inside of an onClick
 
user2620028
and i am losing the reference to this obviously because .bind is changing it to the instance of the react class that is being called inside
 
user2620028
are my only options to create a wrapper function to be bound instead and call the code i want, or the other option being pass this as an argument and reassign in the class
 
I need to see an example.
 
user2620028
let me make a relevant fiddle
 
10:05 PM
I can think of at least two differences between f => f and function(f) { return f; } :) — Benjamin Gruenbaum 7 secs ago
 
people are submitting documentation changes for hats
 
this and .name ?
 
user2620028
wait. i think i am being an idiot
 
user2620028
@luggage i am being an absolute moron nevermind
 
:)
or this and args, @BenjaminGruenbaum
 
user2620028
10:07 PM
well...
 
no difference in practice for that code, though, that I can think of
 
user2620028
i was doing
state.setPage.bind( this, args )
 
user2620028
trying to ask how to avoid it setting this to this
 
user2620028
instead of this referring to state
 
user2620028
and im looking at the code like..... riiiiiiight the first argument is what to set this to
 
user2620028
10:08 PM
i hate knowing how to program but having blonde moments all the time
 
@Luggage observable differences
That is, I write a myFunction that a function as a parameter and tells if it's the first or second.
this and args aren't relevant since they weren't used.
 
toString is one of them
 
Correct.
.name isn't though.
 
.arguments too it seems
 
10:11 PM
the arrow function throws, but the function expression has null
 
Oh cool! Didn't think of that.
!!> (f => f).arguments
 
@BenjaminGruenbaum null
 
Wait, in Chrome this throws :O
!!> (function(f) { return f; }).arguments
 
@BenjaminGruenbaum null
 
in the console at least it throws :S
 
10:12 PM
Uncaught TypeError: 'caller' and 'arguments' are restricted function properties and cannot be accessed in this context.
 
I see it too, I wonder why. Lucky we have @Zirak here.
 
what the console throws for that
 
@BenjaminGruenbaum ah, and .prototype? the arrow function has none
the expression has object
 
odd. the ()=> version has a prototype, but no prototype property
 
@david right, that's the second one - that it has no .prototype and can't be new'd :)
@Luggage that makes perfect sense, it itself is a function instance, but can't be used as a constructor.
 
10:14 PM
!!> Object.getPrototypeOf(f => f)
 
@Luggage "function () {\n}"
 
!!> new (f => f)
 
@BenjaminGruenbaum "TypeError: f => f is not a constructor"
 
Arrow functions can't be constructor and toString are the two I had in mind, I have no idea about the throwing on arguments.
5..arguments doesn't throw, and (f => f).call doesn't throw. Is it a parser bug :O?
Doesn't throw in IE or Firefox.
 
10:15 PM
or does caprica use babel and it's transpiled?
 
I wonder if it's a V8 bug or a console issue.
 
ohh, she's on firefox
 
It throws in a script tag too, and in Node.
This is probably a v8 parser priority bug - nice find @david !
Nope, not a parser bug.
It doesn't work even if you name the reference.
 
what's the bug, NOT throwing?
 
Now I don't know anymore - quick, to the spec!
I think Function.prototype.arguments was never actually standardized.
Ok, both throw in strict mode.
Other browsers don't do this.
Since it's not standard, no one enforces a coherent behavior.
The magic of nonstandard JS, also you lose @david since the spec doesn't define this it's propitiatory extensions :P
 
10:23 PM
The natural beauty of JS.
I like my JS with imperfections.
 
dammit, i lost and i didn't even know i was playing
ahahah zirak
 
@Zirak /dev/null
 
> Arguments objects for strict functions define a non-configurable accessor property "callee" which throws a TypeError exception on access (9.4.4.6).
> Arguments objects for strict functions do not dynamically share their array indexed property values with the corresponding formal parameter bindings of their functions. [(9.4.4)](https://tc39.github.io/ecma262/#sec-arguments-exotic-objects).
It's a strict mode thing
 
@Zirak but chrome throws on sloppy mode.
 
and Edge/FF don't throw at all
 
No it doesn't
@BenjaminGruenbaum Sure they do, in strict mode
 
> The initial implementation of arrow functions in Firefox made them automatically strict. This has been changed as of Firefox 24. The use of "use strict"; is now required.
 
 
10:30 PM
how do i make pretty quote boxes in my messages?
 
` > `
 
@KevinB thank you good sir
 
> > foobar
 
What's interesting is that if you define a sloppy-mode function, you can access its .arguments in strict mode, but a strict mode function's .arguments can't be accessed in sloppy mode.
@BenjaminGruenbaum That's actually strange
 
10:33 PM
!!afk sloppy mode
 
Chrome does handle arrow functions a bit differently, but they're not auto-strict
 
@Zirak cage.youdontsay.gifv.sh
Actually, worth the image.
 
In chrome it also happens with method declarations, async functions, generators and classes
i.e. all the new function declarations
Interesting
I'll make a note to take a look at it
 
10:39 PM
oh, I think I know why
Lemme take a look before verifying with the source
 
hrm, nope, still nothing
 
@Zirak why though :/
 
Classes are enforced strict mode, so they make sense. It seems like v8 however uses the strict property descriptors for sloppy async and generators.
@BenjaminGruenbaum I honestly have no idea
I'll look at it later tomorrow, miiight open a bug
 
@Zirak and arrows
 
@BenjaminGruenbaum Haven't found that code yet
 
11:06 PM
@BenjaminGruenbaum How's that related?
 
@Zirak it shows these function types are asserted to be the same and without prototype.
 
yeah, but that code doesn't seem to deal with strict mode or the descriptors
 
I don't expect the code doing this to deal with strict mode at all - it behaves the same in both modes.
 
Weeeiiirrrddd
This function decides which descriptor map functions get
 
That's it
 
11:14 PM
Very weird
 
oh right, strong mode. That was a weird one.
 
is it just my inexperience, or is that a huge commit?
 
Right they shouldn't have a prototype, but arguments and caller are still fair game
 
11:20 PM
they don't have enough prototype maps :D
 
But they already have SLOPPY_FUNCTION_WITHOUT_PROTOTYPE_MAP_INDEX!
grr, I'll play around with it later
 
@Zirak amazing game
 

« first day (2257 days earlier)      last day (2705 days later) »