I'm starting my adventure with React. I have a trouble with calling the function rvKey from inside the map function.
Finally, this function will be responsible for removing the button that is clicked. But so far, I cannot even console.log a message
Uncaught TypeError: Cannot read property 'rvKey' of undefined
I'm using webpack and material-ui.
class Search extends React.Component {
state = {
keywords: ["One", "Two", "Three"],
};
rvKey = () => {
console.log('111');
// remove this element
}
keywords = () => {
return this.state.keywords.map(function(object, i){
return (
<Button dense mini raised color="default" key={i}>
{object}
<Close
onClick={this.rvKey}
className="icon small"
/>
</Button>
)
})
}
render(){
return (
<Input>
{this.keywords()}
</Input>
);
};
};