These are chat archives for FreeCodeCamp/Help

3rd
Feb 2018
Ken Haduch
@khaduch
Feb 03 2018 02:23
hello all - been away all day, hope I didn't miss anything too exciting?
Stephen James
@sjames1958gm
Feb 03 2018 02:46
@khaduch Nope, don't think so
Ken Haduch
@khaduch
Feb 03 2018 02:46
@sjames1958gm - phew! It does seem like it's pretty quiet here...
Kyle Holm
@thekholm80
Feb 03 2018 03:20
@khaduch :wave:
Ken Haduch
@khaduch
Feb 03 2018 03:20
@thekholm80 - hey there! :wave:
Thanh Son Nguyen
@nguyen-thanhson
Feb 03 2018 07:15
hey can I have a question about SQL?
liuuu
@liuuu
Feb 03 2018 07:45
ReactDOM.render(element, container[, callback]) anyone know about this syntax?
Manish Giri
@Manish-Giri
Feb 03 2018 08:00
@liuuu what about it
liuuu
@liuuu
Feb 03 2018 08:00
the container[, callback]
Manish Giri
@Manish-Giri
Feb 03 2018 08:01
the 2nd option is the DOM element where you want to render your JSX
the third argument is an optional callback, it returns a reference to the component that's being rendered to the DOM
which is null for stateless components
liuuu
@liuuu
Feb 03 2018 08:02
if some one type hello[, callback]
where can I find the definition of this syntax, do you know?
Manish Giri
@Manish-Giri
Feb 03 2018 08:04
the React docs
liuuu
@liuuu
Feb 03 2018 08:05
I don' t mean that, I mean the syntax of (element, container[, callback])
not care about the react part, just this kind thing
any function definition like hello(element, container[, callback])
the third arguments is a optional callback, where is the definition of this kind syntax
here is the closest match I could find on the notation
liuuu
@liuuu
Feb 03 2018 08:16
thanks , 😭 hard to figure it out
Manish Giri
@Manish-Giri
Feb 03 2018 08:19
:+1:
liuuu
@liuuu
Feb 03 2018 08:20
why not render(element, container, [callback])
these guys interesting
Sweet Coding :)
@SweetCodingInc
Feb 03 2018 08:52
@liuuu In documentation, the arguments wrapped within [ and ] are considered to be optional
liuuu
@liuuu
Feb 03 2018 08:53
@SweetCodingInc is there any doc talk about this convention
Sweet Coding :)
@SweetCodingInc
Feb 03 2018 08:55
@liuuu Not that I know of
It's just sort of know thing about optional arguments
Corentin Whyte
@CorySW
Feb 03 2018 15:44

I have a problem with the react recipe box project I don't know how to configure the keys so that they're unique ? any tips ?
I had this warning pop up even though I specified a key

index.js:2178 Warning: Each child in an array or iterator should have a unique "key" prop.

here's the code

render() {
        const initrecipes = this.state.initrecipes.map((recipe) => {
            return (
            <ul>
                <li key={recipe.title}>{recipe.title}</li>
                <li key={recipe.desc}>{recipe.desc}</li>
                <li key={recipe.time}>{recipe.time}</li>
            </ul>
            );
        })
Kyle Holm
@thekholm80
Feb 03 2018 15:52
@CorySW you can use a second argument in map() to get the index of the element, which should be unique to that element. map(element, index)
Corentin Whyte
@CorySW
Feb 03 2018 15:52
@thekholm80 thank you very much, I didn't think about that
CamperBot
@camperbot
Feb 03 2018 15:52
corysw sends brownie points to @thekholm80 :sparkles: :thumbsup: :sparkles:
:star2: 1684 | @thekholm80 |http://www.freecodecamp.org/thekholm80
Kyle Holm
@thekholm80
Feb 03 2018 15:53
:+1:

also, i'd use the key in the topmost level of your return, so

<ul key={ index }>
  ...
</ul>

instead of putting a key in every JSX element

Corentin Whyte
@CorySW
Feb 03 2018 15:58
oh okay nice to know
this actually fixed everything
Kyle Holm
@thekholm80
Feb 03 2018 16:03
excellent
Darren
@DarrenfJ
Feb 03 2018 18:23
morning fCC
Ken Haduch
@khaduch
Feb 03 2018 18:30
@DarrenfJ - hey there, Darren - how are things today?
Darren
@DarrenfJ
Feb 03 2018 23:22
@khaduch been busy listening to podcasts and watching documentaries about big foot and aliens...
you know...
a typical weekend ;)
mitch9141
@mitch9141
Feb 03 2018 23:59
Hi, can someone help me?