These are chat archives for FreeCodeCamp/HelpFrontEnd

23rd
Oct 2018
Brad
@bradtaniguchi
Oct 23 2018 00:00 UTC
There's all the html you gave to react, also dont post huge amounts of code
Hussein Zaki
@Hussein90
Oct 23 2018 00:00 UTC
okay
and after i click delete they disappear @bradtaniguchi
Brad
@bradtaniguchi
Oct 23 2018 00:01 UTC
yea what you put initiall disappears cuse your saying there are none in the state
Hussein Zaki
@Hussein90
Oct 23 2018 00:09 UTC
yeah after i click delete button they removed from the state
@bradtaniguchi
like they weren't there at all
Hussein Zaki
@Hussein90
Oct 23 2018 00:23 UTC
i don't know why these happen @bradtaniguchi
Hussein Zaki
@Hussein90
Oct 23 2018 00:52 UTC
i am really Stuck @all
Brad
@bradtaniguchi
Oct 23 2018 01:18 UTC
@Hussein90 React is rendering your empty arrays. If you don't want that, then your code is working, just not doing what you want. You already know what you want, and know what is currently happening, that's like 80% of the problem, but now you need to go ahead and fix whats not working (the code you posted earlier "resets" the state).
Hussein Zaki
@Hussein90
Oct 23 2018 01:18 UTC
so how to fix it
@bradtaniguchi
Mike Bilyeu
@mbilyeu1
Oct 23 2018 01:22 UTC
Can anyone help me with the first data vis project? I can't get the two last test to pass. https://learn.freecodecamp.org/data-visualization/data-visualization-projects/visualize-data-with-a-bar-chart
Line 114 is what I have but doesn't pass? https://codepen.io/bilyeu1/pen/oajYgJ
Brad
@bradtaniguchi
Oct 23 2018 01:36 UTC
@Hussein90 fix what?
Hussein Zaki
@Hussein90
Oct 23 2018 01:36 UTC
the code you posted earlier "resets" the state)
that
Brad
@bradtaniguchi
Oct 23 2018 01:36 UTC
You know whats wrong with it right?
Hussein Zaki
@Hussein90
Oct 23 2018 01:36 UTC
i want the code to only remove one not all
Brad
@bradtaniguchi
Oct 23 2018 01:37 UTC
so you want to remove something from an array?
Hussein Zaki
@Hussein90
Oct 23 2018 01:37 UTC
yes
by click on delete button
Brad
@bradtaniguchi
Oct 23 2018 01:37 UTC
If you don't know how to remove something from an array, look it up, and apply what you learn to your code
Hussein Zaki
@Hussein90
Oct 23 2018 01:38 UTC
i see it but can't do it with my state
Brad
@bradtaniguchi
Oct 23 2018 01:39 UTC
See what? And can't do what?
Hussein Zaki
@Hussein90
Oct 23 2018 01:39 UTC
see how to remove from arry using splice()
don't know to access it in my component
@bradtaniguchi
Brad
@bradtaniguchi
Oct 23 2018 01:52 UTC
Id recommend figuring out what you dont know and then figuring out how to find the answer
Hussein Zaki
@Hussein90
Oct 23 2018 01:53 UTC
i know i will recommend that also but i didn't get at all
@bradtaniguchi
Brad
@bradtaniguchi
Oct 23 2018 01:55 UTC
If you find yourself still stuck, then you might need to dig deeper or backup and re-evaluate what you actually don't know, since if "learning" the answer to something doesn't actually give you the answer, your probably looking at the wrong question, or missing other understanding of another concept.
If your not sure how to remove items from an array, then find that out, if your not sure how to update state in react, look that up, if your not sure how to remove an item from an array then update its reference in another item look that up, if your not sure what pass by "value vs pass by reference" then look it up, if your not sure how to use "splice" then look that up, etc etc..
Hussein Zaki
@Hussein90
Oct 23 2018 01:57 UTC
you are right
i am sorry
that i am look dumb
but i am really didn't understand
@bradtaniguchi
Stevegolden12
@Stevegolden12
Oct 23 2018 05:40 UTC
@Hussein90 We all make mistakes and we all need help at times. I personally appreciated the fact that you stuck with it.
Hussein Zaki
@Hussein90
Oct 23 2018 08:51 UTC
and i am still stuck with it @Stevegolden12
Hussein Zaki
@Hussein90
Oct 23 2018 09:28 UTC
@all i am still stuck can anyone help me
please
Claudio Restifo
@Marmiz
Oct 23 2018 09:52 UTC
what's the matter?
Hussein Zaki
@Hussein90
Oct 23 2018 09:52 UTC
i have problem with my delete button
@Marmiz
try to click on delete button
the first and then the second one
and then refresh do that vise versa
Claudio Restifo
@Marmiz
Oct 23 2018 09:54 UTC
const dataposts = Object.assign([], this.state.data.posts);
what?
Hussein Zaki
@Hussein90
Oct 23 2018 09:55 UTC
???
Claudio Restifo
@Marmiz
Oct 23 2018 09:55 UTC
why do you want to allocate memory for a new object into an array?
Hussein Zaki
@Hussein90
Oct 23 2018 09:56 UTC
i don't want
Claudio Restifo
@Marmiz
Oct 23 2018 09:56 UTC
so what's that line
cos that's what that line is telling the program to fo
*do
Hussein Zaki
@Hussein90
Oct 23 2018 09:57 UTC
okay
Claudio Restifo
@Marmiz
Oct 23 2018 10:01 UTC

what are you tring to accomplish? Remove the clicked element?

if so why your delete set the state to an empty array?

Hussein Zaki
@Hussein90
Oct 23 2018 10:01 UTC
yes
Claudio Restifo
@Marmiz
Oct 23 2018 10:03 UTC
why your delete set the state to an empty array?
Hussein Zaki
@Hussein90
Oct 23 2018 10:03 UTC
i don't know
Claudio Restifo
@Marmiz
Oct 23 2018 10:04 UTC
who should know it then?
Hussein Zaki
@Hussein90
Oct 23 2018 10:04 UTC
okay i made a mistake
Claudio Restifo
@Marmiz
Oct 23 2018 10:04 UTC
everyone does
no big deal
the main thing however is understeanding
like how can your app show "all the data you had before minus one" if you are telling it that now the data is an empty array?
Jack Lyons
@JackEdwardLyons
Oct 23 2018 10:45 UTC
hey all, anyone wanna pair up on the Cash Register Algorithm Challenge?
cat998
@cat998
Oct 23 2018 12:57 UTC
hello,everybody.I have a problem,how to upload an image to codepen?
A-J Roos
@Asjas
Oct 23 2018 13:01 UTC
@cat998 You can't. Unless you pay for Codepen. So use a free image hosting service like Cloudinary
Daniel Simeonov
@dbsimeonov
Oct 23 2018 13:03 UTC
Guys how can I create my ajax request to stop the script until I have the response. Or with other words im trying to create my response reusable into variables?
Victor Popescu
@VicPopescu
Oct 23 2018 13:05 UTC
you use a global variable and you assign the data to it after the response @dbsimeonov
global meaning, out of the ajax call scope and inside the parent scope where you need it
Daniel Simeonov
@dbsimeonov
Oct 23 2018 13:05 UTC
yes but when I console log my variable outside the scope it will be null as its logging it to me before its assigned
Victor Popescu
@VicPopescu
Oct 23 2018 13:06 UTC
callback is one variant
you put the rest of the code into a function and you pass that function as a callback to your ajax call
and call it on response and pass the data as an argument
Eric Weiss
@eweiss17
Oct 23 2018 13:08 UTC
ya... the information you obtain from the ajax call is only usable within the scope of the call itself... unless you do that callback stuff he is talking about i guess
You can just chain calls within each other though
Victor Popescu
@VicPopescu
Oct 23 2018 13:09 UTC
@dbsimeonov
success: function(data)          
     {   
       doTheRest(data);
     },
@dbsimeonov there is another alternative if you use jquery
you can use deferred objects
cat998
@cat998
Oct 23 2018 13:11 UTC
@Asjas thanks
Daniel Simeonov
@dbsimeonov
Oct 23 2018 13:12 UTC
So basically I should split everything into callback functions and just run my fetch request and chains up down ?
Victor Popescu
@VicPopescu
Oct 23 2018 13:12 UTC
at least the triggering function
meaning the next call in chain
Daniel Simeonov
@dbsimeonov
Oct 23 2018 13:13 UTC
Yep got it, what about promises or constructor as I've never used them but heard that its possible with them
Eric Weiss
@eweiss17
Oct 23 2018 13:13 UTC
you doing some complex calls or just one?
Daniel Simeonov
@dbsimeonov
Oct 23 2018 13:13 UTC
multiple ones for filtering and sorting around 400 elements
Victor Popescu
@VicPopescu
Oct 23 2018 13:14 UTC
@dbsimeonov promises? what js flavor and what frameworks you use?
Daniel Simeonov
@dbsimeonov
Oct 23 2018 13:14 UTC
I'm trying to use it vanilla + jquery
Victor Popescu
@VicPopescu
Oct 23 2018 13:14 UTC
well you don't have promises there
ES5 doesn't have promises
if you use ES6 then it's simple
Daniel Simeonov
@dbsimeonov
Oct 23 2018 13:15 UTC
hmm okay so I will do it with callbacks then
Thanks a lot! Really appreciate it
Victor Popescu
@VicPopescu
Oct 23 2018 13:15 UTC
in jquery the nicest solution is to use deferred objects
and then you can treat it with .when()
it's something like a promise simulation
@dbsimeonov np, good luck!
Daniel Simeonov
@dbsimeonov
Oct 23 2018 13:17 UTC
that looks nice, will test it
Today they literally killed me, first time even I faced xml.. :D
Victor Popescu
@VicPopescu
Oct 23 2018 13:17 UTC
it can be a pain, but after you grasp the concept it's easy
Nicolas Ramirez
@kamatheuska
Oct 23 2018 14:54 UTC
He everyone! is anyone doing or have done the 100 days of coding challenge?
Hussein Zaki
@Hussein90
Oct 23 2018 16:50 UTC
hi @all that's me again i need answer for question in my mind only not a something i can't do the question is theoretically if i have request for me to web app using react.js and to be sort on it and filter on it and i found react-bootstrap-table which is has inside it the function for sort or filter also but i will only call it using import library and then inside return() i called it using JSX to make it happen is that good or no for me to do that it makes me don't need to make function for sort or filter ,i only made one function on the whole app to get data
so what is your opinion
Brad
@bradtaniguchi
Oct 23 2018 16:56 UTC
@Hussein90 Have you looked into the .sort and .filter array methods?
These are "built in" to JS automatically
Hussein Zaki
@Hussein90
Oct 23 2018 16:56 UTC
yes i am talking about if i will use this bootstrap
@bradtaniguchi
Brad
@bradtaniguchi
Oct 23 2018 16:58 UTC
@Hussein90 I'm confused about what exactly your trying todo. Are you going to use the bootstrap-table to do the sort and filter? Or are you ONLY using that table just to sort and filter?
Hussein Zaki
@Hussein90
Oct 23 2018 17:00 UTC
i am saying what if i need to make bootstrap-table and make it sort and filter and found that the bootstrap inside it contains the function i need to make sort and filter
@bradtaniguchi
Brad
@bradtaniguchi
Oct 23 2018 17:01 UTC
@Hussein90 ok, I don't see the problem, I assume you can do either, so what is your question?
Hussein Zaki
@Hussein90
Oct 23 2018 17:01 UTC
i am asking if i do that is that good or no
only using integrate it using JSX @bradtaniguchi
Brad
@bradtaniguchi
Oct 23 2018 17:02 UTC
@Hussein90 whats the alternative(s)? (I'm not a React guy, I'm an Angular guy)
Hussein Zaki
@Hussein90
Oct 23 2018 17:03 UTC
okay
Brad
@bradtaniguchi
Oct 23 2018 17:03 UTC
And what does that have todo with JSX?
Hussein Zaki
@Hussein90
Oct 23 2018 17:04 UTC
i mean like using html code inside of react like if i add something to html tag it happened
@bradtaniguchi
Brad
@bradtaniguchi
Oct 23 2018 17:04 UTC
@Hussein90 I don't understand what your saying
Hussein Zaki
@Hussein90
Oct 23 2018 17:05 UTC
look you know bootstrap right
@bradtaniguchi
Brad
@bradtaniguchi
Oct 23 2018 17:06 UTC
Yes
Hussein Zaki
@Hussein90
Oct 23 2018 17:06 UTC
and also for sure how it works
@bradtaniguchi
let's take this as a example
<button type="button" class="btn btn-primary">Primary</button>
what it will make , it will make blue button
right
what will happen if we change btn-with anything other will change also to be like what it has in his reference
right
@bradtaniguchi
react-bootstrap also work like that for example
Brad
@bradtaniguchi
Oct 23 2018 17:09 UTC

what will happen if we change btn-with anything other will change also to be like what it has in his reference

What?

Hussein Zaki
@Hussein90
Oct 23 2018 17:10 UTC
<TableHeaderColumn dataField='name'  dataSort={ true }  >task Name</TableHeaderColumn>
Brad
@bradtaniguchi
Oct 23 2018 17:10 UTC
Are you asking if you changed the html tag what would happen?
Hussein Zaki
@Hussein90
Oct 23 2018 17:10 UTC
what
make me explain
i am getting to the point

```

<TableHeaderColumn dataField='name' dataSort={ true } >task Name</TableHeaderColumn>

`` if i remove dataSort={ true }` from it , it return not sort

without putting any function by adding only this dataSort={ true } it will be able to sort @bradtaniguchi
Brad
@bradtaniguchi
Oct 23 2018 17:14 UTC
Ok
Hussein Zaki
@Hussein90
Oct 23 2018 17:15 UTC
so if i do that on exchange of making a function is this bad
Brad
@bradtaniguchi
Oct 23 2018 17:15 UTC
What do you mean by bad is my question
Why do you think it could be bad?
Hussein Zaki
@Hussein90
Oct 23 2018 17:16 UTC
like if i am getting interview and do that is bad or no to them , make them refuse to hire me
Brad
@bradtaniguchi
Oct 23 2018 17:17 UTC
@Hussein90 If I asked you to sort and filter the same data without any library can you do it?
Hussein Zaki
@Hussein90
Oct 23 2018 17:20 UTC
i can try to do it
Brad
@bradtaniguchi
Oct 23 2018 17:22 UTC
Then I suggest you learn how todo it before using a library for it, since the sort of interview questions most employers ask are mostly data manipulation and sorting and filtering are easy todo. So you should know how todo it basically blind folded
Hussein Zaki
@Hussein90
Oct 23 2018 17:23 UTC
no i am talking about if they give me task to do it
Brad
@bradtaniguchi
Oct 23 2018 17:23 UTC
@Hussein90 Do what?
Hussein Zaki
@Hussein90
Oct 23 2018 17:24 UTC
do app for the company which interview me
Brad
@bradtaniguchi
Oct 23 2018 17:25 UTC
They probably will ask you in the interview to solve problems, especially for any serious company caring about the quality of developers they hire.
You could end up with a whiteboard and pen, or they can test you online in some live IDE remotely
Otherwise they could send you home with a "take home" project you need todo. But these are usually pretty expansive, not tiny data-manipulation projects
Lia-Sue-Kim
@Lia-Sue-Kim
Oct 23 2018 19:56 UTC
how to test a website before sharing it?
I know that you can look from different devices and browsers but it's not really testing
if possible for free
Brad
@bradtaniguchi
Oct 23 2018 19:59 UTC
@Lia-Sue-Kim Like automated testing?
Lia-Sue-Kim
@Lia-Sue-Kim
Oct 23 2018 20:02 UTC
I don't know what automated test is but for example I'm having trouble with flexbox
it doesn't work with some old devices
it is for this website if you remember https://www.nevci.com
the layout I've created works fine in my devices but when I see someone using a smartphone I ask them to see my website and it's all kind of jumbled up
Brad
@bradtaniguchi
Oct 23 2018 20:05 UTC
Well, I know of platforms that can test your web-app/site on multiple different versions of browsers, but its paid and you need to write up your tests in some way or form
otherwise it won't know what the hell to "test for" with your app
Lia-Sue-Kim
@Lia-Sue-Kim
Oct 23 2018 20:06 UTC
Like its content is out of its box when you see it from an old device for instance
Well as long as it shows the way I created on paper and everything seen like
from my devices
Got it I just want it to look the way i designed it
Brad
@bradtaniguchi
Oct 23 2018 20:07 UTC
I've heard of screenshot tests too, but regardless of how you test your app, you need to run it on older platforms, which AFAIK is a paid service
Lia-Sue-Kim
@Lia-Sue-Kim
Oct 23 2018 20:08 UTC
I see so there is no free version of any software i guess
?
Fair enough
Brad
@bradtaniguchi
Oct 23 2018 20:08 UTC
I don't know of any personally
but even if it was free, youd need to setup some automatic tests
Lia-Sue-Kim
@Lia-Sue-Kim
Oct 23 2018 20:08 UTC
others need to earn something for a living
can you tell me more about automatic test?
Like usually you have to test it manually ?
Brad
@bradtaniguchi
Oct 23 2018 20:11 UTC
Basically you write code to test your code, to verify it works as expected. You could test it manually, but every time you change something you have to manually test it again. Write 1 test and it will test your code forever, great for catching regression
Depending on what your testing, you setup different tests, it sounds like you need UI testing, so stuff like screenshot tests (I think) are what you would want, but I've never used those.
Lia-Sue-Kim
@Lia-Sue-Kim
Oct 23 2018 20:12 UTC
is it some kind of algorithm?
AJ Brommy
@AJ-Brommy
Oct 23 2018 20:12 UTC
might be worth asking around in linux communities, they are well tuned with open source stuff
Brad
@bradtaniguchi
Oct 23 2018 20:12 UTC
what is?
Lia-Sue-Kim
@Lia-Sue-Kim
Oct 23 2018 20:13 UTC
@AJ-Brommy Linux communities where?
@bradtaniguchi you said that you have to write code to test code right
where to do that
Brad
@bradtaniguchi
Oct 23 2018 20:14 UTC
Yea you write the test code, that tests you code (lol). Usually its done via some test runner, like Karma
Karma then takes your code, the test code, and runs the tests, like "expect this function returns true when given these arguments"
So its definitely a technology, not an algorithm
Lia-Sue-Kim
@Lia-Sue-Kim
Oct 23 2018 20:16 UTC
what about UL test
I think I need orginized design
like everything should work fine without programming
pure html and css
User interface design**
Brad
@bradtaniguchi
Oct 23 2018 20:18 UTC
Yea it sounds like you want to test CSS, idk how that would work, but I'm sure it would follow a similar concept
Lia-Sue-Kim
@Lia-Sue-Kim
Oct 23 2018 20:23 UTC
@AJ-Brommy i got this
message
The server at nevci.com sent a HTTP redirect. Your web address has been updated. Please try again.
@bradtaniguchi ok thank you Brad
Hussein Zaki
@Hussein90
Oct 23 2018 21:08 UTC

hi to all
@all
i have this json data

{
  "posts": [{
      "title": "CopyRight Automatico",
      "tags": "[JS]",
      "id": 1,
      "userId": 1,
      "name": "Shopping",
      "dueDate": null,
      "priority": "high",
      "categoryId": 1
    },

  ],

  "categories": [{
      "id": 1,
      "name": "Personal"
    },
    {
      "id": 2,
      "name": "Work"
    }
  ]
  ,
  "subtasks": [
    {
      "id": 1,
      "postId": 1,
      "item": "Milk",
      "done": true,
      "optional": false
    }
  ]
}

look at the posts array you will find categoryId": 1' and at categories you will findid:1` i want when i call post.categoryId i get word personal not number 1 @all any help

Brad
@bradtaniguchi
Oct 23 2018 21:12 UTC
@Hussein90 I see the data, but dont understand what your trying todo.
Hussein Zaki
@Hussein90
Oct 23 2018 21:12 UTC
okay
look at a posts array
@bradtaniguchi
inside it there is property called categoryId
i want when it called not getting me back number 1 but name personal
@bradtaniguchi
Brad
@bradtaniguchi
Oct 23 2018 21:14 UTC
@Hussein90 Why not use the id to get the name?
Hussein Zaki
@Hussein90
Oct 23 2018 21:15 UTC
that my question , because they have the same categoryId right @bradtaniguchi
Brad
@bradtaniguchi
Oct 23 2018 21:15 UTC
Yea, do you know how to get the corresponding category?
Hussein Zaki
@Hussein90
Oct 23 2018 21:16 UTC
no
that my question
@bradtaniguchi
Brad
@bradtaniguchi
Oct 23 2018 21:16 UTC
You'd want to loop over the items in the categories array and when the id matches the one you want, return that object
Hussein Zaki
@Hussein90
Oct 23 2018 21:17 UTC
can you show me
@bradtaniguchi
please :)
Brad
@bradtaniguchi
Oct 23 2018 21:17 UTC
Id rather not give you the answer up front, you should look up the answer and learn it yourself
Hussein Zaki
@Hussein90
Oct 23 2018 21:18 UTC
okay
Brad
@bradtaniguchi
Oct 23 2018 21:18 UTC
Id suggest going thru some javascript courses, either on FCC itself, or on another place like following MDN docs.