These are chat archives for FreeCodeCamp/Help

8th
Jan 2019
Manish Giri
@Manish-Giri
Jan 08 00:40
@psyperl the problem is actually with .fill()
When fill gets passed an object, it will copy the reference and fill the array with references to that object.
you can bypass .fill() entirely
const generateObj = () => ({ prop: false })
const newArr = [...Array(10)].map(_ => generateObj());
console.log(newArr)
newArr[0].prop = true 
console.log(newArr)
BP
@bgq007
Jan 08 00:49
Vs code users. How do we move a tag around? Example. I have some text. I decide I want to wrap an "a" around it. If I select the text it gets wiped out. If I just start putting my "a" in front I will get the auto-close but it puts it in front of my text. So how would I take the close "a" tag and move it to the right? Is it possible or just cut and paste? Seems like I've seen videos of people selecting text and moving it left right up or down. Thanks
abraham anak agung
@padunk
Jan 08 01:47
@bgq007 you can move it up and down with alt + arrow up/ down. I usually just cut and paste it. vs code keyboard ref
BP
@bgq007
Jan 08 01:48
@padunk yes, I know that one. But thanks!
Claudio Restifo
@Marmiz
Jan 08 02:39
:wave: hello campers :smile:
abraham anak agung
@padunk
Jan 08 02:49
Hello, long time no see @Marmiz
Claudio Restifo
@Marmiz
Jan 08 02:50
yeah, been a busy period :smile:
psyperl
@psyperl
Jan 08 03:18
awesome thanks for the review @Manish-Giri
Aditya
@ezioda004
Jan 08 06:39
@kbaig Thats cool, syntax is a bit trippy. Thanks for sharing!
Kranti Nebhwani
@darkphotonKN
Jan 08 08:01
@kbaig thanks a lot
@kbaig just checked your solution, you're right initial state should be data: { COntent: [] } as I'm trying to map on Content before it's ready, and there is only data initialized and not the content property inside data
@ezioda004 i like your solution too - checking if there is a length before trying to map it
@ezioda004 but i never ran into this problem before, not sure how I used to map through data i got from apis, i did it so often but don;t remember this happening. it's probably the fact that there is a array of objects within the array of objects that threw me off. I used to simply set data: [], async await the get request for the data, then map over the array to output whatever in the body. This is the first where the mapping claims that the content is undefined
Aditya
@ezioda004
Jan 08 08:12
@darkphotonKN You must be doing some error checking, since all API requests are async, the initial data have to be undefined. Typically, you have a "Spinner" component or something which is rendered till the data from the API if fetched:
this.state.isLoading ? <Spinner /> : <MyAwesomeComponent props = {this.state.data}  />
Ofcourse, this is just 1 pattern.
May Kittens Devour Your Soul
@diomed
Jan 08 09:30
fruitful lemony :lemon: :lemon:
Garrus Napp
@GarrusNapp
Jan 08 10:02
Hello guys
Need help with React!!
anyone brave here ? :)
Aditya
@ezioda004
Jan 08 10:04
You can post your question; if anyone knows they'll answer.
Garrus Napp
@GarrusNapp
Jan 08 10:06
<Sections>
 <Section1 />
 <Section2 />
</Sections>

I need to pass plenty of Sections into <Section> parent component. I'd like for it to be able to also render section title as string. How'd I go about it?
Niraj Nandish
@Nirajn2311
Jan 08 10:07
@diomed :cat: question with your favourite topic, React, is here :smiling_imp:
Garrus Napp
@GarrusNapp
Jan 08 10:08
<Sections sections=[{<Section1>, "Section1"}, {<Section2>, "Section2"}] />
I thought of this but this seems a bit sketchy
arrs, instead of obj obviously
psyperl
@psyperl
Jan 08 10:14
wonder if <Section1 /> and <Section2 /> should be rendered in Section render function instead? I am new to React so not sure how that should be done
Garrus Napp
@GarrusNapp
Jan 08 10:15
The thing is to make <Section> reusable, so I can use it in different place with other children as well
That's why I'd like to pass them as props.children yet I'dk wherefrom to get the String with their name
<Sections>
 <Section1 title="Section1" />
 <Section2 title="Section2"/>
</Sections>
Maybe I can do this and then something like that,
abraham anak agung
@padunk
Jan 08 10:19
@GarrusNapp you can map sections in <Sections /> component
but where Section came from is it already in state or props?
Garrus Napp
@GarrusNapp
Jan 08 10:20
this.props.children.map(child => ?
All sections and Section parent component are in their own files
May Kittens Devour Your Soul
@diomed
Jan 08 10:24
The average person will have more conversations with bots than with their spouse.
Garrus Napp
@GarrusNapp
Jan 08 10:25
Aditya
@ezioda004
Jan 08 10:25
Talk to the 🤖
psyperl
@psyperl
Jan 08 10:27
could it be something like this?
class Section2 extends React.Component {
  constructor(props) { super(props) }
  render() { return(<div>World</div>)}
}
class Section1 extends React.Component {
  constructor(props) { super(props) }
  render() { return(<div>Hello</div>)}
}
class Section extends React.Component {
  constructor(props){
    super(props)
    this.state = { children: [<Section1 />, <Section2 />] }
  }
  render(){ return (<div>{this.state.children}</div>) }
}
ReactDOM.render( <Section/>, document.getElementById('root') );
Garrus Napp
@GarrusNapp
Jan 08 10:31
@psyperl Hey thanks for answer but the thing is to make <Section /> reusable throught the whole App. In your code it would just render things that are in that state
abraham anak agung
@padunk
Jan 08 10:31
In React, children is special. Maybe you need something like this in so
I never know React have React.children.map interesting
Garrus Napp
@GarrusNapp
Jan 08 10:32
Yes, I only learned about it now too, will give it a try
psyperl
@psyperl
Jan 08 10:47
hehe i managed to pass the children as a param to the Section constructor.. but no idea if this is what's needed.. but I had fun trying it
class Section2 extends React.Component {
  constructor(props) { super(props) }
  render() { return(<div>World</div>)}
}
class Section1 extends React.Component {
  constructor(props) { super(props) }
  render() { return(<div>Hello</div>)}
}
class Section extends React.Component {
  constructor(props){
    super(props)
    this.state = { children: this.props.childrens }
  }
  render(){ return (<div>{this.state.children}</div>) }
}
ReactDOM.render( 
  <Section childrens={[<Section1/>,<Section2/>]}/>, 
  document.getElementById('root') 
);
ReactDOM.render( 
  <Section childrens={[<Section2/>,<Section2/>,<Section2/>]}/>, 
  document.getElementById('root2') 
);
you can change the children state by passing which component you want to attach in childrens Section tag attribute
Claudio Restifo
@Marmiz
Jan 08 10:50
why not simply:
// you can enhance section as you want
const section = () => <div>{this.props.children}</div>


// usage
<Section>
 <A />
 <C />
</Section>

someData.map(el => <Section>{el}</Section>)
if section don't care about which children you pass, or it have to enhance those :)
Garrus Napp
@GarrusNapp
Jan 08 11:09
I've managed to do this :) !! Thanks all for help
Internals of Section needs titles of each children passed, so I did it like so:
<Section>
 <A />
 <C />
</Section>

and in render of section() 
    const tabsArray = React.Children.map(
      children, child => child.props.title
    );
I need both children and their titles to render in yet another component nested in <Section />
That's why all the mess :D
MengHanQi
@MengHanQi
Jan 08 15:30
hello
anyone here?
Binyamin Aron Green
@b3u
Jan 08 15:30
hi
MengHanQi
@MengHanQi
Jan 08 15:31
wo~
workhard yo man
Anand Potukuchi
@anandpotukchi
Jan 08 15:46
hello
anyone know how to query graphql?
@cmccormack
@Marmiz ?
Christopher McCormack
@cmccormack
Jan 08 15:49
@anandpotukchi haven't messed with it yet sorry
Anand Potukuchi
@anandpotukchi
Jan 08 15:50
@ezioda004
May Kittens Devour Your Soul
@diomed
Jan 08 15:56
@cmccormack wanna play hangman?
Christopher McCormack
@cmccormack
Jan 08 15:56
Sure
H as in Hostile
May Kittens Devour Your Soul
@diomed
Jan 08 15:58
T H _
_ _ T _
R _ _ _ _ R
Anand Potukuchi
@anandpotukchi
Jan 08 15:59
@diomed 'O
Christopher McCormack
@cmccormack
Jan 08 15:59
N is in maNcy
May Kittens Devour Your Soul
@diomed
Jan 08 15:59
nO
T H _
_ _ T _
R _ N N _ R
Christopher McCormack
@cmccormack
Jan 08 15:59
E is in Elephantiasis
Anand Potukuchi
@anandpotukchi
Jan 08 15:59
E
May Kittens Devour Your Soul
@diomed
Jan 08 16:00
T H E
_ _ T E
R _ N N E R
as in
:yum:
Anand Potukuchi
@anandpotukchi
Jan 08 16:00
U
May Kittens Devour Your Soul
@diomed
Jan 08 16:00
T H E
_ _ T E
R U N N E R
anyone care to guess?
Anand Potukuchi
@anandpotukchi
Jan 08 16:00
M
May Kittens Devour Your Soul
@diomed
Jan 08 16:01
noM noM noM
Anand Potukuchi
@anandpotukchi
Jan 08 16:01
D
May Kittens Devour Your Soul
@diomed
Jan 08 16:01
[mate runner] :yum:
Christopher McCormack
@cmccormack
Jan 08 16:01
L as in Leprosy
May Kittens Devour Your Soul
@diomed
Jan 08 16:01
noD/L
it's a book, it's a movie, it's a title... it's a what?
Christopher McCormack
@cmccormack
Jan 08 16:02
The Gate Runner
May Kittens Devour Your Soul
@diomed
Jan 08 16:02
no
Christopher McCormack
@cmccormack
Jan 08 16:02
boo
K as in Ketosis
May Kittens Devour Your Soul
@diomed
Jan 08 16:03
yes - care to guess
Christopher McCormack
@cmccormack
Jan 08 16:03
THE KITE RUNNER
May Kittens Devour Your Soul
@diomed
Jan 08 16:03
:congratulations: @cmccormack :ballot_box_with_check: :tada:
Christopher McCormack
@cmccormack
Jan 08 16:03
@diomed /bow
May Kittens Devour Your Soul
@diomed
Jan 08 16:03
correct
seen it maby?
Christopher McCormack
@cmccormack
Jan 08 16:04
no not yet
May Kittens Devour Your Soul
@diomed
Jan 08 16:04
read it, perhaps?
oh well..
Christopher McCormack
@cmccormack
Jan 08 16:04
I kept thinking it was one of those maze runner books or something
May Kittens Devour Your Soul
@diomed
Jan 08 16:04
not even close
brutal reality story :|
Christopher McCormack
@cmccormack
Jan 08 16:04
haha
May Kittens Devour Your Soul
@diomed
Jan 08 16:05
uno mas?
Christopher McCormack
@cmccormack
Jan 08 16:05
I'll have to watch it
Sure!
May Kittens Devour Your Soul
@diomed
Jan 08 16:06
U _ _ A _ _ _
_ A _ _ _ _
Kyle Holm
@thekholm80
Jan 08 16:06
2
Christopher McCormack
@cmccormack
Jan 08 16:06
@thekholm80 :wave:
Kyle Holm
@thekholm80
Jan 08 16:06
@cmccormack hey buddy
Christopher McCormack
@cmccormack
Jan 08 16:06
2
@thekholm80 move to AZ yet?
@diomed L as in Longitude
Kyle Holm
@thekholm80
Jan 08 16:07
no, starting a new job here next week. looks like i'm stuck
Christopher McCormack
@cmccormack
Jan 08 16:07
@thekholm80 you're in Utah right?
what job?
Kyle Holm
@thekholm80
Jan 08 16:08
yeah, utah. doing QA for an electronics manufacturing company
May Kittens Devour Your Soul
@diomed
Jan 08 16:08
@thekholm80 there they were , out in the desert, exposed on the open. and she said - but there's only one savage.
but he said: Hay uno, mas vendrán otros
U _ _ A _ _ _
_ A L L _ _
Kyle Holm
@thekholm80
Jan 08 16:08
is cat taking Spanish lessons?
donde esta la biblioteca, pedro?
Christopher McCormack
@cmccormack
Jan 08 16:09
T as in Tango
May Kittens Devour Your Soul
@diomed
Jan 08 16:09
noT
Manish Giri
@Manish-Giri
Jan 08 16:09
ooh this looks fun
Christopher McCormack
@cmccormack
Jan 08 16:09
@thekholm80 congrats, what kind of work?
Kyle Holm
@thekholm80
Jan 08 16:10
doing QA for an electronics manufacturing company
Manish Giri
@Manish-Giri
Jan 08 16:10
lol
May Kittens Devour Your Soul
@diomed
Jan 08 16:10
@thekholm80 Me llamo T-Bone La araña discoteca
Christopher McCormack
@cmccormack
Jan 08 16:10
@thekholm80 ... thanks
May Kittens Devour Your Soul
@diomed
Jan 08 16:10
@Manish-Giri pls join my lil game of hangman
Christopher McCormack
@cmccormack
Jan 08 16:10
is QA just one thing?
lol
May Kittens Devour Your Soul
@diomed
Jan 08 16:10
I'm sure you all know this expression
Christopher McCormack
@cmccormack
Jan 08 16:10
@diomed B as in Bravado
Kyle Holm
@thekholm80
Jan 08 16:10
oh, final inspection and testing before packaging
Manish Giri
@Manish-Giri
Jan 08 16:10
@diomed S
Jason Luboff
@JLuboff
Jan 08 16:10
Morning
Christopher McCormack
@cmccormack
Jan 08 16:11
@JLuboff :wave:
May Kittens Devour Your Soul
@diomed
Jan 08 16:11
pls guys, noB/S
Anand Potukuchi
@anandpotukchi
Jan 08 16:11
@Manish-Giri any idea about graphql
Jason Luboff
@JLuboff
Jan 08 16:11
@cmccormack What up
Christopher McCormack
@cmccormack
Jan 08 16:11
@diomed V as in Vino
May Kittens Devour Your Soul
@diomed
Jan 08 16:12
yes!
U _ _ A _ _ _
V A L L _ _
Manish Giri
@Manish-Giri
Jan 08 16:12
@anandpotukchi nope, @thekholm80 would be the right person
Christopher McCormack
@cmccormack
Jan 08 16:12
@JLuboff just hanging some men and working on some scripts, you?
@diomed UNCANNY VALLEY
Anand Potukuchi
@anandpotukchi
Jan 08 16:12
@thekholm80 any idea
Jason Luboff
@JLuboff
Jan 08 16:12
Just got into work.. taking care of a few things before continuing on with programming
May Kittens Devour Your Soul
@diomed
Jan 08 16:12
damn, you're good! :congratulations: :ballot_box_with_check:
@cmccormack
Kyle Holm
@thekholm80
Jan 08 16:12
@anandpotukchi any idea about what?
Christopher McCormack
@cmccormack
Jan 08 16:12
WOOHOO
Anand Potukuchi
@anandpotukchi
Jan 08 16:13
graphql
Kyle Holm
@thekholm80
Jan 08 16:13
i have an idea
Christopher McCormack
@cmccormack
Jan 08 16:13
@thekholm80 What part of Utah? I'm growing to like that place, might try to move there in the next few years
May Kittens Devour Your Soul
@diomed
Jan 08 16:13
U-TA
Kyle Holm
@thekholm80
Jan 08 16:13
@cmccormack i'm in Provo area, about 30 min south of salt lake
May Kittens Devour Your Soul
@diomed
Jan 08 16:13
H is silent
Kyle Holm
@thekholm80
Jan 08 16:14
UTA runs our busses and trains lol
Christopher McCormack
@cmccormack
Jan 08 16:14
@thekholm80 such a pretty place, I want to take a bike trip up there
seems a lot of tech companies are opening new offices there as well
Kyle Holm
@thekholm80
Jan 08 16:14
pedal bike or motor bike?
Anand Potukuchi
@anandpotukchi
Jan 08 16:15
@thekholm80 https://www.gatsbyjs.org/packages/gatsby-source-medium/ i wnant to add this to my site
and i have no idea of graphql
okay i ll figure it out in the morning
Christopher McCormack
@cmccormack
Jan 08 16:15
@thekholm80 maybe both if I decide to get a new motorcycle
Kyle Holm
@thekholm80
Jan 08 16:15
i don't know what gatsbyjs is
Christopher McCormack
@cmccormack
Jan 08 16:15
probably pedal
Anand Potukuchi
@anandpotukchi
Jan 08 16:15
good nighr ppl
Christopher McCormack
@cmccormack
Jan 08 16:15
@anandpotukchi see ya
gatsby is used for JAM stacks
it's pretty cool
Manish Giri
@Manish-Giri
Jan 08 16:16
isn't it a static site generator for react
Kyle Holm
@thekholm80
Jan 08 16:16
@cmccormack pedal bikes are too masochistic for me, but there's a lot of good motorcycle riding here
Christopher McCormack
@cmccormack
Jan 08 16:16
I heard Midway is the best biking in the country so gotta try it!
Kyle Holm
@thekholm80
Jan 08 16:17
it's pretty up there, not far from where I am
Christopher McCormack
@cmccormack
Jan 08 16:22
We're going to try for a trip up to Heber again this year, will definitely check out the other sites again
Kyle Holm
@thekholm80
Jan 08 16:22
oh right on, wave when you drive past
Christopher McCormack
@cmccormack
Jan 08 16:22
will do haha
Souvik Kundu
@souvik88
Jan 08 16:56
Is this the right chat room to discuss Responsive web design projects when stuck?
Christopher McCormack
@cmccormack
Jan 08 17:01
@souvik88 Sure! Here or the HelpFrontEnd channel are fine for that
Souvik Kundu
@souvik88
Jan 08 17:09
Thanks @cmccormack
May Kittens Devour Your Soul
@diomed
Jan 08 18:40
The mind is your dark overlord