Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • Aug 17 09:32
    User @bjorno43 unbanned @linkin-park
  • Jun 20 21:19
    @bjorno43 banned @shenerd140
  • Apr 25 17:13
    @mstellaluna banned @cmal
  • Jan 08 22:05
    @mstellaluna banned @dertiuss323
  • Nov 07 2018 04:42
    User @texas2010 unbanned @ows-ali
  • Nov 02 2018 16:25
    @texas2010 banned @ows-ali
  • Oct 12 2018 05:50
    @bjorno43 banned @NACH74
  • Oct 05 2018 23:02
    @mstellaluna banned @JomoPipi
  • Sep 16 2018 12:21
    @bjorno43 banned @yash-kedia
  • Sep 16 2018 12:16
    @bjorno43 banned @vnikifirov
  • Sep 05 2018 08:12
    User @bjorno43 unbanned @androuino
  • Sep 05 2018 07:38
    @bjorno43 banned @androuino
  • Aug 23 2018 16:57
    User @bjorno43 unbanned @rahuldkjain
  • Aug 23 2018 16:23
    @bjorno43 banned @rahuldkjain
  • Jul 29 2018 14:13
    User @bjorno43 unbanned @jkyereh
  • Jul 29 2018 01:00
    @bjorno43 banned @jkyereh
  • Jul 10 2018 22:09
    @bjorno43 banned @manafn
  • Jul 06 2018 15:20
    @texas2010 banned @imlegend19
  • Jul 03 2018 12:28
    @bjorno43 banned @vbvmatta
  • Jun 29 2018 13:54
    @bjorno43 banned @OGTechnoBoy
Christopher McCormack
@cmccormack
And what troubleshooting have you done?
you don't have a valid json file in your codesandbox, how can you be troubleshooting at all?
You can use the link I sent you yesterday to test in codesandbox
Hussein Zaki
@Hussein90
i updated it
Christopher McCormack
@cmccormack
you have an error in your code; review the error and continue troubleshooting
Hussein Zaki
@Hussein90
okay
yeah the index is not identify
onclick={this.deletePost.bind(this, index)}
Christopher McCormack
@cmccormack
@Hussein90 in React you should use onClick
You need to create index somewhere... maybe in posts.map(post => (?
Hussein Zaki
@Hussein90
like that
var index =   ???
Christopher McCormack
@cmccormack
well that's one way to do it
but you need to figure that out. This is basic JavaScript, if you don't have a variable declared, you can't reference it
hint: the map callback has multiple arguments. MDN
@Hussein90 have you gone through the React course on FCC? It may be a good refresher that can fill in some concerns/gaps
Hussein Zaki
@Hussein90
it works now but it delete all
Christopher McCormack
@cmccormack
@Hussein90 I can tell you that deletePost is coded incorrectly. Walk through your logic and try to determine what's going on
Hussein Zaki
@Hussein90
i am doing that now
Aita Kane
@aita-kane
hello anyone where I can volunteer as a developper please ?
Hussein Zaki
@Hussein90
@cmccormack
i figured it because of that
Object.assign([], this.state.posts);
Christopher McCormack
@cmccormack
@Hussein90 what are you assigning to data in your setState?
And I'm not asking because I don't know, I want you to dig into it
Hussein Zaki
@Hussein90

i know because of that thank you

data: dataposts

under deletePost

Eric Weiss
@eweiss17
@aita-kane look for an opensource project and try to contribute that way
Hussein Zaki
@Hussein90

i changed to

this.state.posts

and to this

this.posts

and i also changed the 'setState' assign to

dataposts: dataposts
Kirk Clemons
@kcclemo
@aita-kane You can browse through this collection of open source projects to see if there are any that fit your niche or interests:
https://firstcontributions.github.io/
Christopher McCormack
@cmccormack
@Hussein90 that isn't the problem
think about what you are assigning to data
Hussein Zaki
@Hussein90
 data: { posts: null, categories: null, }
Christopher McCormack
@cmccormack
@Hussein90 if you assign const dataposts = Object.assign([], this.state.data.posts); dataposts to data, what do you think data will look like then?
Hussein Zaki
@Hussein90
it will be mess
@cmccormack
Christopher McCormack
@cmccormack
@Hussein90 can you be more specific? You need to figure out what will happen and then you can figure out how to fix it
Hussein Zaki
@Hussein90

because i get data from

this.state.data.posts

and then resend it again to data.posts

@cmccormack
Christopher McCormack
@cmccormack
@Hussein90 that is not what you are doing
how about logging the value of your state after you update and see for yourself?
don't guess, log!
Hussein Zaki
@Hussein90

i made a

console.log(dataposts)

and it comes

undefined
Christopher McCormack
@cmccormack
ok.. you need to figure out why
Hussein Zaki
@Hussein90
that the point i didn't get it
Brad
@bradtaniguchi
so you have given up at this point?
Hussein Zaki
@Hussein90
no i am still thinking
but i am stuck with it
Brad
@bradtaniguchi
like @cmccormack said, time to work the issue now. Try different things. When stuff goes wrong you start programming, until then your just typing :P
Hussein Zaki
@Hussein90
okay
Hussein Zaki
@Hussein90
@bradtaniguchi i am trying
Hussein Zaki
@Hussein90
i am really stuck until now i don't know what is the problem really!!!!!!
i am really trying very hard
Brad
@bradtaniguchi
@Hussein90 You have the code your having issues with on codepen?
Hussein Zaki
@Hussein90
yes but in codesandbox