These are chat archives for FreeCodeCamp/Help

15th
Jan 2019
Claudio Restifo
@Marmiz
Jan 15 03:02
@angelparkour499 that can be achieved with some JS :)
Levis
@agabyte
Jan 15 05:22
hi
Anand Potukuchi
@anandpotukchi
Jan 15 05:45
hi @agabyte
@Marmiz are you online
anyone kow react and have used axios
Levis
@agabyte
Jan 15 05:52
having a hard time getting fontawesome fonts to show up in a codepen, anyone had this problem before?
Oh hi @anandpotukchi
Anand Potukuchi
@anandpotukchi
Jan 15 05:54
@agabyte use anther cdn
and check ifthe url is working - click on th eye icon
Levis
@agabyte
Jan 15 05:54
the url works
Anand Potukuchi
@anandpotukchi
Jan 15 05:54
then try another cdn
or another mirro
(don't know hat it's called
Levis
@agabyte
Jan 15 05:59
nope, that didn't work either.
here's my codepen if you don't mind taking a look
I put the fontawesome tag in my react component as well as my html but it does not show up in the preview
Anand Potukuchi
@anandpotukchi
Jan 15 06:03
ti's fas fa-play
(i think)
which elmebt are you tring to giv it o
Levis
@agabyte
Jan 15 06:05
a span element
Anand Potukuchi
@anandpotukchi
Jan 15 06:08
wait
are you sing class or className
yup. it's a problem with the icons
the cdn is fine but the icons are not rendering'
@agabyte
Levis
@agabyte
Jan 15 06:09
I'm using class
Anand Potukuchi
@anandpotukchi
Jan 15 06:10
Levis
@agabyte
Jan 15 06:11
I wonder if there is a specific version of fontawesome that will work
Anand Potukuchi
@anandpotukchi
Jan 15 07:04
i need soneone to help
Item:  Object {
[12:31:48]   "by": "LinuxBender",
[12:31:48]   "descendants": 0,
[12:31:48]   "id": 18904550,
[12:31:48]   "score": 2,
[12:31:48]   "time": 1547486330,
[12:31:48]   "title": "Alias is designed to give users more control over smart assistants",
[12:31:48]   "type": "story",
[12:31:48]   "url": "https://github.com/bjoernkarmann/project_alias",
[12:31:48] }
[12:31:48] Item:  Object {
[12:31:48]   "by": "bilifuduo",
[12:31:48]   "descendants": 13,
[12:31:48]   "id": 18904561,
[12:31:48]   "kids": Array [
[12:31:48]     18904892,
[12:31:48]     18905045,
[12:31:48]   ],
[12:31:48]   "score": 63,
[12:31:48]   "time": 1547486422,
[12:31:48]   "title": "Seminal deep learning papers",
[12:31:48]   "type": "story",
[12:31:48]   "url": "http://find.xyz/map/9-seminal-deep-learning-papers-696a57a7",
[12:31:48] }
```
i ned to render these objects one fater the other
it's not an a rray
do i convert it into an array
and hw do irender
@Marmiz
@alpox
@ezioda004
and anyone lse
Niraj Nandish
@Nirajn2311
Jan 15 07:06
@anandpotukchi this is the data you got using axios
Anand Potukuchi
@anandpotukchi
Jan 15 07:06
yes
1000+ more
Niraj Nandish
@Nirajn2311
Jan 15 07:07
And each one is an object
And you want all of them to be in an array
Anand Potukuchi
@anandpotukchi
Jan 15 07:08
i just want them to render to the dom
so do i convert it into an array
any other way of rendering
Niraj Nandish
@Nirajn2311
Jan 15 07:10
Ill have to remember as the last time i used axios was 3 months ago and in a vue project with :cat:
Anand Potukuchi
@anandpotukchi
Jan 15 07:12
@Nirajn2311 there's notjng concerning axios
IMO
it's renderingobjects
Claudio Restifo
@Marmiz
Jan 15 07:25
@anandpotukchi how's the data structure? just n objects? It's not contained into another structure like a map or array?
Anand Potukuchi
@anandpotukchi
Jan 15 07:25
@Marmiz nope
i mean its just objects
Claudio Restifo
@Marmiz
Jan 15 07:26
@anandpotukchi you ask some data to an endpoint and it replies with 1000+ objects?
Anand Potukuchi
@anandpotukchi
Jan 15 07:26
let me share
Claudio Restifo
@Marmiz
Jan 15 07:27
you sure you are asking the correct "question" ?
Anand Potukuchi
@anandpotukchi
Jan 15 07:27
yes
i wanrt to render these objects to the dom
it's NOT an an arrray
it's the hackernews api
Claudio Restifo
@Marmiz
Jan 15 07:30
@anandpotukchi what's your query?
Claudio Restifo
@Marmiz
Jan 15 07:32
@anandpotukchi it's an array of ID
Anand Potukuchi
@anandpotukchi
Jan 15 07:33
then ran anothwwe req
isnide it
Claudio Restifo
@Marmiz
Jan 15 07:34
@anandpotukchi so you are already looping, on each element ID
that will reply with a single obj. Render that
Anand Potukuchi
@anandpotukchi
Jan 15 07:35
 componentDidMount() {

        axios
        .get(source + newStories)
        .then( response => {
            const ids = response.data;
                //console.log("IDs: ", ids);

                for(var i = 0; i<= ids.length; i++) {
                      //console.log("ID# ", ids[i]); 
                     axios 
                     .get(source + 'item/' + ids[i] + '.json?print=pretty')
                     .then( res => {
                        var items =  res.data;
                            console.log(items);

                     })     
                }

                this.setState({
                    items 
                 }); 


        })  
        .catch(function (error) {
           console.log("Error: ", error);
          });  
    }
Claudio Restifo
@Marmiz
Jan 15 07:36
[allmyID].map(id => <MyAwesomeComponent id=id />)
then myAwesomeComponent does the individual Query and render the single obj
Anand Potukuchi
@anandpotukchi
Jan 15 07:37
what's [allmyID]
Claudio Restifo
@Marmiz
Jan 15 07:37
your first query
@anandpotukchi or following along your structure, you need each sub-query to populate an array of responses, and add that to the state
bc so far your items is undefined outside the then callback
Anand Potukuchi
@anandpotukchi
Jan 15 07:39
my head is spinning
Claudio Restifo
@Marmiz
Jan 15 07:40
                for(var i = 0; i<= ids.length; i++) {
                      //console.log("ID# ", ids[i]); 
                     axios 
                     .get(source + 'item/' + ids[i] + '.json?print=pretty')
                     .then( res => {
                        var items =  res.data;
                            console.log(items);

                     })     
                }
this means you will have lots of different concurrent queries, each indipendent from the other
do you follow me on this or not?
Anand Potukuchi
@anandpotukchi
Jan 15 07:43
yes
@Marmiz
Claudio Restifo
@Marmiz
Jan 15 07:46
So how you expect your state to be after each individual query?
Anand Potukuchi
@anandpotukchi
Jan 15 07:48
it would be populate d with eithe rev eything
or with the last res
@Marmiz
alpox
@alpox
Jan 15 07:53
@anandpotukchi
axios
        .get(source + newStories)
        .then( response =>
          Promise.all(ids.map(id => axios.get(`${source}item/${id}.json?print=pretty')))
        )
        .then(results => {
          const items = results.map(result => result.data);
          console.log(items);
          this.setState({ items });
       })
       .catch(error => {
         console.log("Error: ", error);
       });
Anand Potukuchi
@anandpotukchi
Jan 15 07:57
i got the same resposonse @alpox
alpox
@alpox
Jan 15 07:58
@anandpotukchi Not exactly. Now you have an array :D
Anand Potukuchi
@anandpotukchi
Jan 15 08:01
@alpox can you guve me the ssame thing withou promises
i still dont uderstand
wait
Claudio Restifo
@Marmiz
Jan 15 08:03
@alpox :clap:
I was hoping to guide him into the "no loop inside promises" route :) :) :)
alpox
@alpox
Jan 15 08:04
@Marmiz Hmm but you can do it - depends on what effect you want
If you want the items to get in one after another as soon as they arrive :D
Claudio Restifo
@Marmiz
Jan 15 08:05
@alpox I guess he want a HN / News Feed clone.
I was hoping for him to realize to split the concers :)
alpox
@alpox
Jan 15 08:05
@anandpotukchi Without promises will be a bit hard to give you that ;) I'd have to make quite a setup to get the effect of Promise.all with callbacks
@Marmiz Fair enough :D
Claudio Restifo
@Marmiz
Jan 15 08:06
@alpox considering he uses React, I think he want a feed effect like the one they have, so that each element is indipendent and if one crashes or fail the whole page still works
alpox
@alpox
Jan 15 08:10
Ah ok. I didn't know the context enough then
And HN / News Feed is nothing I know
Anand Potukuchi
@anandpotukchi
Jan 15 08:11
@alpox ?
Claudio Restifo
@Marmiz
Jan 15 08:11
@alpox I was hoping to reach the gotcha of:
mainQuery.map(id => <IndividualFeed id={id}/>)
Anand Potukuchi
@anandpotukchi
Jan 15 08:12
@Marmiz where do i run the sond query here
Claudio Restifo
@Marmiz
Jan 15 08:12
IndividualFeed is a component that takes an ID and run a different query based on that id
ie your nested loop
with its own loader, error, and such
Anand Potukuchi
@anandpotukchi
Jan 15 08:13
so the other compoent can be on aother pages
@Marmiz
Claudio Restifo
@Marmiz
Jan 15 08:14
so that you split the ideas. You can have your main page doing the first quetry. Then each "block" of UI do its own job indipendent from each other
Claudio Restifo
@Marmiz
Jan 15 08:20
@anandpotukchi, @alpox solution is brilliant! you should go with it!
(p.s. kudos)
Anand Potukuchi
@anandpotukchi
Jan 15 08:21
getting promise rejection
let me try to figure it out
alpox
@alpox
Jan 15 08:22
@Marmiz Yours is just as well or better suited :D
Claudio Restifo
@Marmiz
Jan 15 08:24
@alpox I was thinking of a way to do that without Promises... any idea?
my only idea is having an array of functions and execute a next once each finish...
alpox
@alpox
Jan 15 08:25
@Marmiz I'd just create a helper function which does the same as Promise.all
Just with callbacks instead
alpox
@alpox
Jan 15 08:36
@Marmiz
function all(cbs, cb) {
  let numCollected = 0;
  const errors = [];
  const results = [];

  for(let i = 0; i < cbs.length; i++) {
    cbs[i]((err, result) => {
      if(err) errors.push(err);
      else results[i] = result;

      numCollected += 1;
      const hasErrors = errors.length;
      if(numCollected === cbs.length) {
        if(hasErrors)
          cb(errors);
        else
          cb(null, results);
      }
    })
  }
}

all([
  cb => setTimeout(() => cb(null, "foo"), 500),
  cb => setTimeout(() => cb(null, "bar"), 1000)
], console.log);
Its not pretty but thats what I put together for short :D
Claudio Restifo
@Marmiz
Jan 15 08:39
@alpox I just got mine now... I feel ashamed :)
const chainAsync = fns => {
  let curr = 0;
  const last = fns[fns.length - 1];
  const next = () => {
    const fn = fns[curr++];
    fn === last ? fn() : fn(next);
  };
  next();
};


// usage
let tot = [];
chainAsync([
  next => {
    axios.get(`https://hacker-news.firebaseio.com/v0/item/${18909552}.json?print=pretty`).then(r => {
      tot = [...tot, r.data];
      next()
      })
  },
  next => {
    axios.get(`https://hacker-news.firebaseio.com/v0/item/${18909552}.json?print=pretty`).then(r => {
      tot = [...tot, r.data];
      next()
      })
  },
  () => {
   // do something with total
    console.log(tot)
  }
]);
alpox
@alpox
Jan 15 08:40
Ah you still use promises? I did it with callback style only :D
Hmmm But Promise.all does not chain
It runs in parallel
Anand Potukuchi
@anandpotukchi
Jan 15 08:40
.................................
i dont udersatnd a thing
just gonna go chill and come back and have a look later
Claudio Restifo
@Marmiz
Jan 15 08:41
@alpox yeah but I guess I cannot uses promises as well
lemme try with timeouts

@alpox technically works.

chainAsync([
  next => {
    console.log('0 seconds');
    setTimeout(next, 1000);
  },
  next => {
    console.log('1 second');
    setTimeout(next, 1000);
  },
  next => {
    console.log('2 second');
  }
]);

and of course its not it parallel... it's actually specifically a chianing...
gosh I'm bad :shit:

alpox
@alpox
Jan 15 08:46
@Marmiz Yea its chaining :D chaining would be as easy as:
const chainPromises = promises => promises.reduce((a,b) => a().then(b));

chainPromises([
  () => delay(1000).then(() => console.log("heeeh")),
  () => delay(1000).then(() => console.log("foo"))
])
Claudio Restifo
@Marmiz
Jan 15 08:46
f**k.... that's a million times better
Karma Drukpa
@coderkarma
Jan 15 08:47
I need to know promises better so looking at the code
@alpox @Marmiz could you show me async and await examples?
I am trying to understand those well .
Claudio Restifo
@Marmiz
Jan 15 08:50
@coderkarma to chain stuff with async/await? that's even easier to read
async doStuff() => {
  const a = await something;
  const b = await somethingElse;
 const c = await different(a, b);

  return c;
}
alpox
@alpox
Jan 15 08:52
async foo = () => {
  for(...) {
    await xyz();
  }
}
As well :D
Anand Potukuchi
@anandpotukchi
Jan 15 08:53
@alpox just help me convert a list o fobj to an array of obj
your old code is crashing the app
alpox
@alpox
Jan 15 08:53
@anandpotukchi lists and arrays are the same in js. All just arrays (lists generally don't exist apart from arrays)
Anand Potukuchi
@anandpotukchi
Jan 15 08:54
i meant series objects
wait
  "by": "coloneltcb",
[14:15:19]   "descendants": 0,
[14:15:19]   "id": 18904856,
[14:15:19]   "score": 2,
[14:15:19]   "time": 1547488717,
[14:15:19]   "title": "Shoot the Facebook Messenger",
[14:15:19]   "type": "story",
[14:15:19]   "url": "https://theoutline.com/post/6971/facebook-messenger-wants-to-trick-you-into-consenting-to-letting-them-put-ads-on-your-phone?zd=2&zi=mhfuvkom",
[14:15:19] }
[14:15:19] Object {
[14:15:19]   "by": "LyalinDotCom",
[14:15:19]   "descendants": 3,
[14:15:19]   "id": 18904860,
[14:15:19]   "kids": Array [
[14:15:19]     18905108,
[14:15:19]     18905034,
[14:15:19]     18904943,
[14:15:19]   ],
[14:15:19]   "score": 2,
[14:15:19]   "time": 1547488769,
[14:15:19]   "title": "My first computer was an IBM 486sx 25 PC, what was yours? [Twitter]",
[14:15:19]   "type": "story",
[14:15:19]   "url": "https://twitter.com/LyalinDotCom/status/1084865197653688320",
[14:15:19] }
Claudio Restifo
@Marmiz
Jan 15 08:54
@anandpotukchi also your "problem" is not the data structure... but that you want to render stuff during an async operation inside another async operation.
Think exactly how you want to proceed
Anand Potukuchi
@anandpotukchi
Jan 15 08:54
this should be enclosed by an array
@Marmiz i don't know async
Karma Drukpa
@coderkarma
Jan 15 08:55
@Marmiz @alpox thanks
Anand Potukuchi
@anandpotukchi
Jan 15 08:55
just naive calls
Claudio Restifo
@Marmiz
Jan 15 08:55
@anandpotukchi they are async, meaning that the response is not immediate
Karma Drukpa
@coderkarma
Jan 15 08:56
await waits until other stuff are done?
Anand Potukuchi
@anandpotukchi
Jan 15 08:57
@Marmiz just help me obj be in a array
Claudio Restifo
@Marmiz
Jan 15 08:57
@coderkarma yep, it's like a "pause" button.
Wait here until we are done with this :)
Anand Potukuchi
@anandpotukchi
Jan 15 08:57
so i can call arr[x]
which would return an object
Claudio Restifo
@Marmiz
Jan 15 08:59

@anandpotukchi you don't see it clearly. The issue is not that you have object instead of arrays.
You are "asking" 15 different people 15 different questions.
One may answer now, one may be on the toilet and you have to wait. One may be unavailable.

Now you have to decide... shall I wait until I got all my 15 replies, and while they arrive I set them aside?
Or shall I do something each time one arrive?

Anand Potukuchi
@anandpotukchi
Jan 15 09:01
@Marmiz get all 15 and call them one by one
Claudio Restifo
@Marmiz
Jan 15 09:03
so wait until you have all your answers
then Promise.all is your friend
Anand Potukuchi
@anandpotukchi
Jan 15 09:09
        .get(source + newStories)
        .then( response =>
          Promise.all(ids.map(id => axios.get(`${source}item/${id}.json?print=pretty')))
        )
        .then(results => {
          const items = results.map(result => result.data);
          console.log(items);
          this.setState({ items });
       })
       .catch(error => {
         console.log("Error: ", error);
       });
@alpox is this ycode of yurs proper
it says thre's an unterminated te,plate
Anand Potukuchi
@anandpotukchi
Jan 15 09:15
@Marmiz @alpox
alpox
@alpox
Jan 15 09:16
@anandpotukchi Yea I seem to have put there the wrong literal
axios.get(`${source}item/${id}.json?print=pretty`)
This should be right
Claudio Restifo
@Marmiz
Jan 15 09:22

perhaps

Promise.all(ids.map(...))

ids should be `response.data?

but @anandpotukchi you should know best of us
Anand Potukuchi
@anandpotukchi
Jan 15 09:24
FUUUUUUUUUUUUUUUUUUUUUUUUUUU
Niraj Nandish
@Nirajn2311
Jan 15 09:38
@anandpotukchi its so confusing that you are confused :laughing:
Anand Potukuchi
@anandpotukchi
Jan 15 10:36
@Marmiz
i got your point now
:smile:
@Nirajn2311 :laughing:
Anand Potukuchi
@anandpotukchi
Jan 15 13:11
Anyoen rmemeber how to do a for loop insie render() method in react
@Nirajn2311 ?
Anand Potukuchi
@anandpotukchi
Jan 15 13:36
@ezioda004
Aditya
@ezioda004
Jan 15 13:38
You can just use a regular for loop inside render()
Inside JSX its a different story, you'll have to use forEach or other HOFs.
Anand Potukuchi
@anandpotukchi
Jan 15 13:57
 for(var i=0; i <= itemIDs.length; i++) {
             <Story    id=itemIDs[i] />
            }
@ezioda004
Aditya
@ezioda004
Jan 15 13:58
This is inside render() or return?
Anand Potukuchi
@anandpotukchi
Jan 15 13:58
return()
Aditya
@ezioda004
Jan 15 13:59
Cant use for inside return
Use .map or something.
Rahul Nayak
@pragyes31
Jan 15 14:03
Hi guys, i want to increase the border of an element from the existing 2 px to 5px just for a second and then back to 2 px. How do i achieve this using JavaScript?
Kaz Baig
@kbaig
Jan 15 14:04
@pragyes31 you can select it and then change the style.border-width property
Anand Potukuchi
@anandpotukchi
Jan 15 14:04
@kbaig any pointers
Kaz Baig
@kbaig
Jan 15 14:05
@anandpotukchi follow what adi said
Anand Potukuchi
@anandpotukchi
Jan 15 14:05
@kbaig map didnt work
Kaz Baig
@kbaig
Jan 15 14:05
We don't know what you want to do
Anand Potukuchi
@anandpotukchi
Jan 15 14:05
@kbaig i have an array
and i want to loop throiugh it
``
or(var i=0; i <= itemIDs.length; i++) {
             <Story    id=itemIDs[i] />
            }
Rahul Nayak
@pragyes31
Jan 15 14:06
@kbaig it permanently changes the border width. How do i keep it for just one sec and remove it
Kaz Baig
@kbaig
Jan 15 14:06
@pragyes31 set a timeout that changes it back
Rahul Nayak
@pragyes31
Jan 15 14:07
@kbaig basically i am looking for a way to change css property for a sec using JavaScript. Any other way that using setTimeout?
those are your two ways of timing things in js
Anand Potukuchi
@anandpotukchi
Jan 15 14:11
Is it just me or is this community becoming unfrirendlier/rude/serious by the day
Rahul Nayak
@pragyes31
Jan 15 14:12
@kbaig thanks man. I'll take a look
Kaz Baig
@kbaig
Jan 15 14:13
@pragyes31 No problem
Philip Durbin
@pdurbin
Jan 15 14:13
Is it? I hope not. We should keep it friendly.
Kaz Baig
@kbaig
Jan 15 14:15
@pragyes31 btw, I'd recommend toggling a class on the element you want to change rather than changing the style directly. Then have the diff border prop as css
@pragyes31 That way you keep the styles in one place
Anand Potukuchi
@anandpotukchi
Jan 15 14:16
 const { itemIDs } = this.state
    return(
       <>
          {userIDs.map(id =>
          <li key={id.objectID}>
            {userIDs.id}
          </li>
        )}

       </>
   ); 
};
@kbaig
do you see anything wrong
Kaz Baig
@kbaig
Jan 15 14:17
userIDs is an array but you're calling userIDs.id within the jsx
Anand Potukuchi
@anandpotukchi
Jan 15 14:18
i didnt get you
Aditya
@ezioda004
Jan 15 14:18
Arrays can have property, probably not the case with his tho
Kaz Baig
@kbaig
Jan 15 14:18
Yeah I'm just assuming
Here: {userIDs.id}
Does userIDs have an id property?
Niraj Nandish
@Nirajn2311
Jan 15 14:31
@anandpotukchi thats when our mascot is not there
Anand Potukuchi
@anandpotukchi
Jan 15 14:31
@Nirajn2311 ?
Anand Potukuchi
@anandpotukchi
Jan 15 14:47
render() {
  const { itemIDs } = this.state;
    return(
       <>
        {itemIDs.map(id =>
              <Story id={itemIDs.id} />
        )}


       </>
   ); 
};
}
returns null
@kbaig @ezioda004
Aditya
@ezioda004
Jan 15 14:50
Whats is itemIDs?
Anand Potukuchi
@anandpotukchi
Jan 15 14:51
an array
of inegers
Each child in an array must have a unique 'key' prop
this is the warning
so I added ` it
<Story key={id.objectID} id={itemIDs.id} />
Niraj Nandish
@Nirajn2311
Jan 15 15:05
@anandpotukchi i meant when our mascot, :cat: , is not here the group feels lonely and serious
Anand Potukuchi
@anandpotukchi
Jan 15 15:43
@ezioda004 is there anything wrong with the map
render() {
  const { itemIDs } = this.state;
    return(
       <>
        {itemIDs.map(id =>
              <Story  
               key={id.objectID}  
              id={itemIDs.id} />
        )}


       </>
   ); 
}
enw map
Christopher McCormack
@cmccormack
Jan 15 15:45
@anandpotukchi your Story id will be the same for all values
if that's an iterable, I don't think you mean to use that value for id
Anand Potukuchi
@anandpotukchi
Jan 15 15:46
i need to ierate through ana rray
Christopher McCormack
@cmccormack
Jan 15 15:47
yes
Anand Potukuchi
@anandpotukchi
Jan 15 15:48
so if it returns the same id
@cmccormack \
how do i fix this
Christopher McCormack
@cmccormack
Jan 15 15:51
@anandpotukchi does itemIDs have a property of id? If it is an array, it probably does not
Anand Potukuchi
@anandpotukchi
Jan 15 15:52
you're right
Christopher McCormack
@cmccormack
Jan 15 15:52
other than the id attribute I don't see anything else wrong
without seeing the sructure of the itemIDs member objects
Kaz Baig
@kbaig
Jan 15 15:52
He said it's an array of integers
Christopher McCormack
@cmccormack
Jan 15 15:53
oh then id.objectID isn't going to work
if id is an integer, anyway
Anand Potukuchi
@anandpotukchi
Jan 15 15:53
just usde id
Christopher McCormack
@cmccormack
Jan 15 15:54
yup that should be it for both attributes
Anand Potukuchi
@anandpotukchi
Jan 15 15:55
it's the hackernews api
fyi
@cmccormack
doe this seem right?
render() {
  const { itemIDs } = this.state;
    return(
       <>
        {itemIDs.map(id =>
              <Story  
               key={id}  
              id={itemIDs.id} />
        )}


       </>
   ); 
}
Christopher McCormack
@cmccormack
Jan 15 15:57
@anandpotukchi if itemIDs is an array of integers why are you trying to access the property id on an array?
Anand Potukuchi
@anandpotukchi
Jan 15 15:57
i dont remember
and i dont know
Christopher McCormack
@cmccormack
Jan 15 15:58
well the array most likely has no property id, so maybe remove that and replace it with something you know does exist and is unique for that element
Anand Potukuchi
@anandpotukchi
Jan 15 15:58
now how do i do it
@cmccormack
Christopher McCormack
@cmccormack
Jan 15 16:00
@anandpotukchi do what exactly? If you need id to be unique, can you not do the same thing you did for key?
Anand Potukuchi
@anandpotukchi
Jan 15 16:26
<>
        itemIDs.map((id) => 
        <Story id={id.toString()}/>

        );

       </>
Cant' find variable: id
@cmccormack
Christopher McCormack
@cmccormack
Jan 15 16:28
@anandpotukchi you're missing your expression wrapper ( { ... } )
Anand Potukuchi
@anandpotukchi
Jan 15 16:29
oh got it
Anand Potukuchi
@anandpotukchi
Jan 15 16:41
@cmccormack do you know React native
Christopher McCormack
@cmccormack
Jan 15 16:41
never heard of it
Anand Potukuchi
@anandpotukchi
Jan 15 16:41
sorry
native
Christopher McCormack
@cmccormack
Jan 15 16:42
Nope not used it yet, sorry :/
Anand Potukuchi
@anandpotukchi
Jan 15 16:47
@cmccormack do you know how i can use this in the child compoenent Story
?
Christopher McCormack
@cmccormack
Jan 15 17:06
@anandpotukchi use what exactly?
Anand Potukuchi
@anandpotukchi
Jan 15 17:38
The value of id
Aditya
@ezioda004
Jan 15 17:40
Idk native either but I'm confident basic JS/React doesnt change with using native.
You should probably go through the React/FP section again if you're struggling with mapping/iterating.
Anand Potukuchi
@anandpotukchi
Jan 15 18:14
I'm having problems calling it in another component
Pretty sure that the map is right
Anyway will look into the FP section again
Christopher McCormack
@cmccormack
Jan 15 18:16
@anandpotukchi I'm sorry but you don't really provide enough detail in your questions at times, so it's difficult to help you out. You really should consider creating a codesandbox/codepen and sharing parts of your code, if not the whole thing via git if it's not private
Aditya
@ezioda004
Jan 15 18:17
@cmccormack You dont like taking random guesses about 2 lines of code?
Christopher McCormack
@cmccormack
Jan 15 18:18
@ezioda004 not a big fan, no
Kaz Baig
@kbaig
Jan 15 18:18
that's rude of you
cmccormack @cmccormack presents wrists
Aditya
@ezioda004
Jan 15 18:19
I agree, this community has become very unfriendly/rude these days
Christopher McCormack
@cmccormack
Jan 15 18:19
When the :cat: is away the :mouse: will play
Niraj Nandish
@Nirajn2311
Jan 15 18:43
And the foxes are there to catch those :mouse:
I still dont get how some you do that purple thing like text :confused:
Christopher McCormack
@cmccormack
Jan 15 18:44
what purple thing??
oh try /me [text]
kbaig @kbaig testing 123
Christopher McCormack
@cmccormack
Jan 15 18:45
that goes way back and seems to be included in a lot of chat apps even if not well advertised
Nirajn2311 @Nirajn2311 realises that there are commands in gitter
psyperl
@psyperl
Jan 15 18:45
/me [test]
Christopher McCormack
@cmccormack
Jan 15 18:45
@psyperl fail
psyperl
@psyperl
Jan 15 18:46
it's common irc
not surprised.. i only get surprised when i succeed
Christopher McCormack
@cmccormack
Jan 15 18:47
lol
ArielLeslie @psyperl does the fail flail
May Kittens Devour Your Soul
@diomed
Jan 15 19:22
· · · − − − · · ·
Niraj Nandish
@Nirajn2311
Jan 15 19:23
Where are you :cat:
May Kittens Devour Your Soul
@diomed
Jan 15 19:23
on reddit :yum:
Niraj Nandish
@Nirajn2311
Jan 15 19:24
Watching cat massage memes presumably
May Kittens Devour Your Soul
@diomed
Jan 15 19:24
yeah, smth like this
Niraj Nandish
@Nirajn2311
Jan 15 19:25
:laughing:
diomed @diomed :cat: is not impressed
Niraj Nandish
@Nirajn2311
Jan 15 19:41
EXPOSURE
May Kittens Devour Your Soul
@diomed
Jan 15 19:42
reading about a lady who called 911 and said: Would you send that very nice police officer over to jump me again?
apparently her car battery was dead, and he helped her once
Niraj Nandish
@Nirajn2311
Jan 15 19:51
:laughing:
Ene Catalin
@EneCatalin
Jan 15 20:39
bit of help ?
what kind of regression should I use if I have discrete data (ie: years)
and, I guess, categorical data
Josh Goldberg
@GoldbergData
Jan 15 20:40
What is your prediction problem? @EneCatalin
Kaz Baig
@kbaig
Jan 15 20:40
Multilinear no?
Ene Catalin
@EneCatalin
Jan 15 20:40
I've no idea
i tried like a tard to use linear regression before I realized, like 2h later, that wait, I don't have continuous data
so...
I have years and a scale from 1 to 6
Josh Goldberg
@GoldbergData
Jan 15 20:41
What are you predicting? @EneCatalin
Ene Catalin
@EneCatalin
Jan 15 20:41
actually I have ages*
if age influences the (injury) scale
Josh Goldberg
@GoldbergData
Jan 15 20:42
Do a logistic regression @EneCatalin
Ene Catalin
@EneCatalin
Jan 15 20:42
so, pretty much, if old people die easier from blunt trauma
Kaz Baig
@kbaig
Jan 15 20:42
I'm not sure why a linear wouldn't work
Prob not the best fit, but I don't get it why it doesn't work
Ene Catalin
@EneCatalin
Jan 15 20:42
i can show you
maybe I am doing it wrong
but what I get is a graph with just lines
since I have 6 values for trauma
Josh Goldberg
@GoldbergData
Jan 15 20:43
It will have problems. You should use a logistic regression, which bounds output between 0 and 1. Actually you will need multinomial logistic regression, which is a general logistics for k outputs @EneCatalin
Kaz Baig
@kbaig
Jan 15 20:43
Is this excel?
Ene Catalin
@EneCatalin
Jan 15 20:43
it's R
but I really suck at it
Kaz Baig
@kbaig
Jan 15 20:43
yikes I'd be clueless
Josh Goldberg
@GoldbergData
Jan 15 20:43
I’m an R user
Kaz Baig
@kbaig
Jan 15 20:43
I remember in excel sometimes it'd take each of the 6 values as its own line like you're describing
Ene Catalin
@EneCatalin
Jan 15 20:43
I should be too but I skipped a few too many labs
wait, why multinominal logistic regression ?
Josh Goldberg
@GoldbergData
Jan 15 20:44
Logistic only handles binary
Multinomial is generalized to k outputs, or as many classes as you want
Ene Catalin
@EneCatalin
Jan 15 20:44
nice, thx
can't believe it took me at least 1-2h to realize I have discrete vars
lol
Josh Goldberg
@GoldbergData
Jan 15 20:45
@EneCatalin I’ve spent longer on more trivial stuff. Don’t worry. All a part of the learning process.
Ene Catalin
@EneCatalin
Jan 15 20:46
btw does it matter if I have a huge (like 20k+) ammount of data
should I just take samples ?
is this the same thing ?
Multivariate Adaptive Regression
Josh Goldberg
@GoldbergData
Jan 15 20:47
Need a link
nvm, think it's ML stuff
Josh Goldberg
@GoldbergData
Jan 15 20:47
Ene Catalin
@EneCatalin
Jan 15 20:47
yeah it's the first google result :D
also, since someone asked what happens during normal regression
latest attempt
(well, it wasn't regression but anyway)
image.png
Josh Goldberg
@GoldbergData
Jan 15 20:51
You need a monotonic function for categorical data.
Ene Catalin
@EneCatalin
Jan 15 20:52
so I can do what I tried above ?
I pretty much copy pasted from stackoverflow
Josh Goldberg
@GoldbergData
Jan 15 20:53
You should be able to fit a multinomial logistic using that page as a guide.
Ene Catalin
@EneCatalin
Jan 15 20:53
right, i've installed the packages and ima get to it
finally :D
Josh Goldberg
@GoldbergData
Jan 15 20:54
Wonderful! 😄
Ene Catalin
@EneCatalin
Jan 15 20:54
it was so weird to always get graphs like that and somehow it wouldn't click
like, it's obvious when you see the graph
ofc it's not tied together, they're, well, discrete lol
Josh Goldberg
@GoldbergData
Jan 15 20:54
Visualization is your best tool for modeling and diagnostics
Ene Catalin
@EneCatalin
Jan 15 20:55
R actually looks nice as a lang
Josh Goldberg
@GoldbergData
Jan 15 20:55
R is wonderful. I am currently at the RStudio Conference
Ene Catalin
@EneCatalin
Jan 15 20:55
but i've noticed something, it imports stuff from every language on gods earth
Josh Goldberg
@GoldbergData
Jan 15 20:56
R is an interface language. @EneCatalin. Obviously since it’s interpretted
Ene Catalin
@EneCatalin
Jan 15 20:56
right, using that ide too
what do people talk about at ide conferences though ?
i mean it's a conf about the ide or the lang too ?
Josh Goldberg
@GoldbergData
Jan 15 20:57
Tons of talks and a ton of learning. Also great networking @EneCatalin
Ene Catalin
@EneCatalin
Jan 15 21:00
oh right, the networking
that alone is worth more than all the learning
Josh Goldberg
@GoldbergData
Jan 15 21:00
Agreed.
Ene Catalin
@EneCatalin
Jan 15 21:02
forgot to say, @GoldbergData , thanks for the help :D
the bot is dead though, no longer giving points
Josh Goldberg
@GoldbergData
Jan 15 21:03
@EneCatalin My pleasure! Let me know how it works out. You should split your data with train and test so you can validate the model.
Ene Catalin
@EneCatalin
Jan 15 21:03
wait, I don't get that
why would I train it ?
don't you just dump all your data in your regression function
Josh Goldberg
@GoldbergData
Jan 15 21:03
You train a model so you can reuse it for prediction on data the model has not seen
Ene Catalin
@EneCatalin
Jan 15 21:03
then let it do the thing ?
Josh Goldberg
@GoldbergData
Jan 15 21:04
So you split the data to validate the model works on data it has not seen
Ene Catalin
@EneCatalin
Jan 15 21:04
wait, is regression that advanced ?
I thought, well at least linear regression, was just a formula that worked with any continuous data
also, say I had 26k elements, would 1k be good for testing ?
Josh Goldberg
@GoldbergData
Jan 15 21:05
Normally it’s 80/20 split train/test
So save 20% of your data for test
But you must randomly sample the data so there is no bias
Ene Catalin
@EneCatalin
Jan 15 21:06
so, always take 80% of data
Josh Goldberg
@GoldbergData
Jan 15 21:06
so randomly assign some data train, and some data test
Ene Catalin
@EneCatalin
Jan 15 21:06
really had no idea regression is used for this stuff
Josh Goldberg
@GoldbergData
Jan 15 21:06
It’s not a rule. You can use whatever amount of data for the split. Just be sensible. Also read up on train/test data set splits. There are a lot of resources
Ene Catalin
@EneCatalin
Jan 15 21:06
just assumed it drew the regression line and the variables around it
speaking of, since I have an insane number of vars, won't it look just weird af ?
Josh Goldberg
@GoldbergData
Jan 15 21:07
It does. This is extra you do to make sure the model works on new data. Imagine if tesla did not validate their models and just sent self-driver cars on the road
They want to test to make sure the model works on new data before deploying it
Ene Catalin
@EneCatalin
Jan 15 21:08
so, just to make sure I got it
they feed the function a LOT of data, train it well
then drop some more to see if it actually predicted correctly
Josh Goldberg
@GoldbergData
Jan 15 21:09
@EneCatalin You got it
Ene Catalin
@EneCatalin
Jan 15 21:09
right, but in regression there were always the points around the regression line
Josh Goldberg
@GoldbergData
Jan 15 21:09
Once you have a model object fit in R. You can use the predict() function to feed the model new data to predict on. You can then measure the error rate
Ene Catalin
@EneCatalin
Jan 15 21:09
I forget the name, but they were pretty much deviantions from our obv
Josh Goldberg
@GoldbergData
Jan 15 21:09
You’re talking about residuals
Ene Catalin
@EneCatalin
Jan 15 21:09
yes
Josh Goldberg
@GoldbergData
Jan 15 21:10
Residuals are different here. Since you have a logistic
Anyway. Read up on some of these topics. I have to take off for more.
Ene Catalin
@EneCatalin
Jan 15 21:10
had no idea, only looked at the linear one
good luck
Josh Goldberg
@GoldbergData
Jan 15 21:10
Happy coding!
Jose Pagan
@josepagan
Jan 15 22:28
It only took me 18 hours to understand promises!!! :D