r/reactjs • u/acemarke • Mar 02 '18
Beginner's Thread / Easy Questions (March 2018)
Last month's thread was pretty busy - almost 200 comments . If you didn't get a response there, please ask again here!
Soo... Got questions about React or anything else in its ecosystem? Stuck making progress on your app? Ask away! We’re a friendly bunch. No question is too simple.
The Reactiflux chat channels on Discord are another great place to ask for help as well.
27
Upvotes
View all comments
Show parent comment
1
u/homercrates Mar 25 '18 edited Mar 25 '18
Sometimes the easiest stuff just trip me up. ugh. That worked great. I can now specify by index. However. the <div> itself when I inspect react tab in dev tools does not show my onClick={} it is rendering the <div> as I want. It when I throw in a {index} in there it is displaying the correct index count. It just is not quite making the <div> appropriate. I have another compnent else where with the same onClick command works. when clicked it logs 'click' but when I click these <div>'s there is no response. I am leaning in the direction that I am rendering these wrong in some way. Becuase inspecting the <div> in react shows no other functions. its like they are hollow blank <div>;s with out an onClick={}. (react was hollering about unique keys so i threw in a unique key just to keep the peace.)
import React, { Component } from 'react'; import Aux from '../../hoc/Auxiliary';
// const listHand = myHand.map((inHand) => <li key={inHand.toString()}>{inHand}</li>);
class Hand extends Component {
state = { currentHand: [ [1,1], [1,2], [1,3], [2,1], [2,2], [2,3], [3,1], [3,2], [3,3] ] }
} export default Hand;
Not exactly sure.. but the <div> is broke it doesn't even mention an onClick={} function in the react inspect of dev tools. So when i click on the <div> it doesn't simply console.log. are my index values then disapearing after I assign them? Should i be using key={} instead? (no i tried passing key back into the clickHandler.. that doesn't work. my <div> is pretty much broke I think and the reason I get no click response... I think i need to look into prev state new state.. maybe i have 2 different versions of state at this point..)
thanks for the help sir by the way.