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
Eric Weiss
@eweiss17
wait what? if you have only = then it will always be true
BrianWilliams28
@BrianWilliams28
oh
you mean in the first if statement
Eric Weiss
@eweiss17
ya
BrianWilliams28
@BrianWilliams28
1 sec
Eric Weiss
@eweiss17
no in the dropdown.style.visibility if statement
BrianWilliams28
@BrianWilliams28
yeah ok you're right
that fixed it
@eweiss17 thanks
Hussein Zaki
@Hussein90
@cmccormack yes, check it i updated

the problem is i don't know where to put

delEvent={this.deletePost.bind(this, index)}

this code

Hussein Zaki
@Hussein90
@cmccormack
Christopher McCormack
@cmccormack

@Hussein90

<button onclick={delEvent}>Delete</button>

Can you not just replace delEvent with your code?

Hussein Zaki
@Hussein90
@cmccormack i tried but not working
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