I have create come component in reactJs, consist of 2 button which handle each onClick function, But when I run the code "myfunction is not defined" error is appear. I want to redirect page to specified address when button triggered. Whats wrong with my code?
import React, { Component } from 'react';
import { Link } from 'react-router-dom';
class MainMenu extends React.Component {
constructor(props){
super(props);
this.slotClick = this.slotClick.bind(this);
this.freqClick = this.freqClick.bind(this);
}
slotClick = (e) => {
e.preventDefault();
}
freqClick = (e) => {
e.preventDefault();
}
render() {
return (
<div>
<input type="button" value="By Time Slot" onClick={ slotClick } />
<input type="button" value="By Frequency" onClick={ freqClick } />
</div>
)
}
}
export default MainMenu;
You need to access the functions from this
. And also you don't need to bind()
because the functions are Arrow Functions.
render() {
return (
<div>
<input type="button" value="By Time Slot" onClick={ this.slotClick } />
<input type="button" value="By Frequency" onClick={ this.freqClick } />
</div>
)
}
I would like to volume mount a directory from a Docker container to my work station, so when I edit the content in the volume mount from my work station it updated in the container as well. It would ...
I would like to volume mount a directory from a Docker container to my work station, so when I edit the content in the volume mount from my work station it updated in the container as well. It would ...
So, the parent class Select declares this.elem as a DOM-element <select> and this.value, that links to a value of selected option class Select { constructor(classList, isTwoLevel, index){ ...
So, the parent class Select declares this.elem as a DOM-element <select> and this.value, that links to a value of selected option class Select { constructor(classList, isTwoLevel, index){ ...
The whole idea is to take users input in a form and display their input in a JSON object. In state I have an array and inside it another array. My Form.js looks like this, state= { groups:[{ ...
The whole idea is to take users input in a form and display their input in a JSON object. In state I have an array and inside it another array. My Form.js looks like this, state= { groups:[{ ...
In componentDidMount I'm trying to get data called topic from /api/topics/${params.TopicId route then from response I want to send only topic.user_id to another route and get whole user as response. ...
In componentDidMount I'm trying to get data called topic from /api/topics/${params.TopicId route then from response I want to send only topic.user_id to another route and get whole user as response. ...