I'm making list using onsenui and react. but I cannot call a bind from onchanged.
I couldn't figure out.... Does anyone can solve this?
this is my code. I'd like to call handlechanged method from input item. But then, Cannot read property 'bind' of undefined is raised.
export default class MainPage extends React.Component {
constructor(props) {
super(props);
this.state = {
selectedValue: "myself",
destinations: ["myself","somebody"],
};
}
handleChange(value) {
this.setState({selectedValue: value});
}
renderRadioRow(row) {
return (
<ListItem key={row} tappable>
<label className='left'>
<Input
inputId={`radio-${row}`}
checked={row === this.selectedValue}
onChange={this.handleChange.bind(this, row)}
type='radio'
/>
</label>
<label htmlFor={`radio-${row}`} className='center'>
{row}
</label>
</ListItem>
)
}
render() {
return (
<Page renderToolbar={this.renderToolbar}>
<p style={{textAlign: 'center'}}>
test
</p>
<List
dataSource={this.state.destinations}
renderRow={this.renderRadioRow}
/>
</Page>
);
}
}
<>toolbar button that you used) are for runnable examples. Your example isn't runnable, so it should be in a code block (the{}toolbar button). But even better would be making it runnable, since Stack Snippets support ReactJS.cannot read X of undefined? I keep seeing these questions and in 99% of the cases the reason is readily apparent - the error message says everything needed. You are accessing X from some variable that happens to beundefined. Suggested course of action - find out why and either prevent it or don't access X. Match to your needs. The rest of the questions are about the same happening in a third party library. In that case, it's usually a problem of not using it correctly. Suggested course of action - find if you've misconfigured it or are miscalling it.