Created
July 5, 2018 01:35
-
-
Save MostlyFocusedMike/e57f9f4b54d306da704f4857e85d2b1b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// src/components/CatInputs.js | |
import React from "react" | |
const CatInputs = (props) => { | |
return ( | |
props.cats.map((val, idx)=> { | |
let catId = `cat-${idx}`, ageId = `age-${idx}` | |
return ( | |
<div key={idx}> | |
<label htmlFor={catId}>{`Cat #${idx + 1}`}</label> | |
<input | |
type="text" | |
name={catId} | |
data-id={idx} | |
id={catId} | |
value={props.cats[idx].name} | |
className="name" | |
/> | |
<label htmlFor={ageId}>Age</label> | |
<input | |
type="text" | |
name={ageId} | |
data-id={idx} | |
id={ageId} | |
value={props.cats[idx].age} | |
className="age" | |
/> | |
</div> | |
) | |
}) | |
) | |
} | |
export default CatInputs |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I have did same but React giving me this error TypeError: undefined has no properties is occured.
