I want to pass the onChange from child to parent. I don't even know if that is the correct way of putting it. But here is my code. The code worked previously but I am trying to break down my code into smaller components and dealing with the errors. If you would like more code, I am happy to share. I am a bit new to React. I don't know what I am doing wrong. The error is basically that the function which takes the event isn't getting anything.
Parent:
<Inputs hasInputs={hasInputs} onSubmit={this.handleSubmit} thoughtProp={this.state.thought} onChange={this.handleChange} />
Child:
import React from 'react'
import { Input } from '../Input.js'
export const Inputs = (props) => {
return (
<form className="flex-item-main form" onSubmit={props.onSubmit}>
<ol>
{props.thoughtProp.map((input, index) => (
<Input type='text' onSubmit={props.onSubmit} key={index} value={input} onChange={(event) => props.onChange(event, index) } className='textInputs' />
))}
{ props.hasInputs ? (
<input className='submitThoughts' type='submit' value='Submit Thought!' />
) : (
null
)}
</ol>
</form>
)
}
console.login your onChange function and post what is getting you inside the onChange function in event.