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
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
here is the link
Brad
@bradtaniguchi
So whats the issue again?
What have you tried? And what are you trying todo?
Hussein Zaki
@Hussein90
when i click on it ,it delete every thing in the page i want only to be indiviual
Brad
@bradtaniguchi
click on what? What do you mean by "i want only to be individual"
Hussein Zaki
@Hussein90
when i click on delete button i want only which is beside it to be delete not all the page
Brad
@bradtaniguchi
@Hussein90 Have you looked at the docs for splice?
Hussein Zaki
@Hussein90
not really i am looking at it now
Brad
@bradtaniguchi
Yea I recommend making sure you understand what your using, and not just copy-pasting code.
Hussein Zaki
@Hussein90
okay
Brad
@bradtaniguchi
@cmccormack you still around to help @Hussein90 ?
Christopher McCormack
@cmccormack
working atm
I know the answer and have pointed directly at it @Hussein90 you need to put some logs in and try to figure out what you're changing that is breaking it
Take your current function and at least try to log something...
  deletePost = (index, e) => {
    const dataposts = Object.assign([], this.state.data.posts);
    dataposts.splice(index, 1);
    this.setState({ data: dataposts }, () => console.log(this.state.data));
  };
above I added a log statement that will run when setState has completed
try that, then try to determine why your code will fail after running the deletePost method
Hussein Zaki
@Hussein90
now in console.log it changed to an object and still disappear all
Brad
@bradtaniguchi
What is in the object, since that's the state of the app
Hussein Zaki
@Hussein90
getting the info of the first post
in arry like
{title: "CopyRight Automatico", tags: "[JS]", id: 1, userId: 1, name: "Shopping", …
Christopher McCormack
@cmccormack
yup, and what was data prior to that?
  deletePost = (index, e) => {
    console.log(this.state.data) // <= Add this log
    const dataposts = Object.assign([], this.state.data.posts);
    dataposts.splice(index, 1);
    this.setState({ data: dataposts }, () => console.log(this.state.data));
  };
Hussein Zaki
@Hussein90
now when i click on for example one the first button the info of the second appear and vise versa also the same