I have the following variable, registerForm
, that has been assigned an array of components. This variable has been defined outside of the Panel
class.
const registerForm = [
<div key={0} style={styles.form.inlineContainer}>
...
<TextField
floatingLabelText="First Name"
hintText="First Name"
floatingLabelFixed={true}
style={styles.form.inlineContainer.spacing}
underlineFocusStyle={styles.form.field.borderColor}
floatingLabelFocusStyle={styles.form.field.color}
floatingLabelStyle={styles.form.field.fontSize}
onChange={(input) => this.handleInput(input)}
/>
...
</div>
];
I then have a class which has a function handleInput
. When something is typed into the text field, the following error is produced: _this.handleInput is not a function
export default class Panel extends React.Component {
constructor() {
super();
this.state = {
panel: 0
}
}
handlePanelChange = (panel) => {
this.setState({
panel: panel
});
};
handleInput = (input) => {
console.log(input);
};
render() {
const panel = this.state.panel;
const form = (panel === 0) ? signInForm : registerForm;
return (
{form}
);
}
}
If possible, how can I get the onChange
event to call handleInput
?