These are chat archives for FreeCodeCamp/HelpJavaScript

28th
Dec 2018
Pagnito
@Pagnito
Dec 28 2018 01:47 UTC

i cant understand why i cant use

res.write(html)
res.end()

thats what the instructor is doing and everyone on stack overflow, but for me res.end() gets called before write
is write recently async or sometihng?

Pagnito
@Pagnito
Dec 28 2018 03:10 UTC
oh apprently res.write has a callback
oof thank god
Ankur sharma
@ankur1163
Dec 28 2018 08:41 UTC
Anyone know whats the best way to animation in react
alpox
@alpox
Dec 28 2018 09:08 UTC
@ankur1163 there are transition groups which are fairly common to use
@ankur1163 ofc. In the end you mostly use css animations. If they are not enough you can still reside to any anination library
Ankur sharma
@ankur1163
Dec 28 2018 11:39 UTC
@alpox ok , so simple transitions are good enough
these will also work
lets say I have start stop button
and i want to use fade out, fade in animation
that will work in this situation?
Nate Mallison
@NJM8
Dec 28 2018 11:54 UTC
Can anyone advise how to properly do error reporting in my application? For example a user tries to add a contact and for some reason it fails, I want the http call reponse captured and sent to me so I know what went wrong.
alpox
@alpox
Dec 28 2018 12:36 UTC
@ankur1163 should work with transition groups
@NJM8 best would be to keep around
Nate Mallison
@NJM8
Dec 28 2018 13:40 UTC
Hm?
Nate Mallison
@NJM8
Dec 28 2018 13:57 UTC
So I have a branch in git I'm getting back to that is a few weeks old. I tried to merge master and it has 92 merge conflicts. :scream:
Should I just force the merge? What do you do in these cases?
I can't look through them all, seems a waste of time
Ohhh,
I was looking at staged changes as well, nvm
Nate Mallison
@NJM8
Dec 28 2018 14:26 UTC
Screen Shot 2018-12-28 at 9.25.55 AM.png
🙄
Jason Luboff
@JLuboff
Dec 28 2018 16:06 UTC
Morning :wave:
Christopher McCormack
@cmccormack
Dec 28 2018 16:37 UTC
@JLuboff yo morning
Jason Luboff
@JLuboff
Dec 28 2018 16:37 UTC
Yo yo
What up
Christopher McCormack
@cmccormack
Dec 28 2018 16:38 UTC
nm coffee and blogs, loving the holidays :)
what about you?
Jason Luboff
@JLuboff
Dec 28 2018 16:39 UTC
Starting to do some refactoring (breaking out more components, clean up some methods, etc) and building up a computer to image
Christopher McCormack
@cmccormack
Dec 28 2018 16:42 UTC
nice man, is it pretty quiet at work right now?
Jason Luboff
@JLuboff
Dec 28 2018 16:43 UTC
Ya, not too much going on
So since you're here...might as well ask you a React question

So, I reuse code similar to this

<div className="field">
        <label className="label">Supervisor's Name</label>
        <div className="control">
          <InputField
            type={"text"}
            placeHolder={"Supervisor's Name"}
            value={props.jsaForm.name}
            onChange={props.inputName}
            required={true}
          />
        </div>
      </div>

So I want to change that to its own component.

const Field = (props) => (
  <div className="field">
    <label className="label">{props.label}</label>
    <div className="control">
      {props.formElement}
    </div>
  </div>
)

But...I feel like I should be doing something with children instead here...?

Christopher McCormack
@cmccormack
Dec 28 2018 16:47 UTC
if field is a simple component with a class, then yeah, you should probably just wrap props.children in the div and then pass the sub components as children to Field instead of declaring it explicitly within Field
unless you want Field to always have those components inside
Jason Luboff
@JLuboff
Dec 28 2018 16:48 UTC
Field will always have a label and then some sort of formElement (input, select, etc)
Christopher McCormack
@cmccormack
Dec 28 2018 16:50 UTC
ah then where you have props.formElement you can just use children, or you can do it how you have it, either work pretty much the same. Personally I think children looks nicer
Jason Luboff
@JLuboff
Dec 28 2018 16:52 UTC
Would I still be passing in props, or just children? ({children}) =>... or (props, {children}) =>... (not sure if that is even valid lol)
Christopher McCormack
@cmccormack
Dec 28 2018 16:53 UTC
props.children is anything you nested inside the component from the calling component
I think you're looking for ({children, ...props}) => ... maybe?
Jason Luboff
@JLuboff
Dec 28 2018 16:54 UTC
Ah

So ultimately.. I'm looking to have

<Field label="My Label">
  <InputField
            type={"text"}
            placeHolder={"Supervisor's Name"}
            value={props.jsaForm.name}
            onChange={props.inputName}
            required={true}
          />
<Field />

Or would the label part not be correct?

I guess I could just test it..
Christopher McCormack
@cmccormack
Dec 28 2018 16:59 UTC
doesn't label need to have a for unless it is wrapping the element?
Jason Luboff
@JLuboff
Dec 28 2018 16:59 UTC
for?
Christopher McCormack
@cmccormack
Dec 28 2018 17:00 UTC
yeah <label for="id-of-element">Label Text</label>
Jason Luboff
@JLuboff
Dec 28 2018 17:01 UTC
oh... don't think I've ever used for in a label
The above appears to work though
Christopher McCormack
@cmccormack
Dec 28 2018 17:04 UTC
can you click the label to select the input?
Jason Luboff
@JLuboff
Dec 28 2018 17:05 UTC
It's just a regular label to sit above the input field. I'm not using checkbox/radios
Christopher McCormack
@cmccormack
Dec 28 2018 17:06 UTC
but you could :)
Jason Luboff
@JLuboff
Dec 28 2018 17:08 UTC
They would be the children if that was the case in which they would have different type of label :)