Hi,
I am new to Meteor so please bear with me. I have a button component for which, onClick event is not firing. Here is my code.
First the container for the component “DisplayButton”
import React, {Component, PropTypes} from 'react';
import {createContainer} from 'meteor/react-meteor-data';
import ReactDOM from 'react-dom';
import DisplayButton from './DisplayButton.jsx';
class ComponentTrial extends Component {
toggleDisplay(e) {
console.log("Let's toggle the display");
}
render() {
<div className="ComponentTrialContainer">
<DisplayButton onClick={this.toggleDisplay.bind(this)} />
</div>
}
}
export default createContainer(() => {
return {
currentUser: Meteor.userId(),
};
}, DisplayButton);
Now the code for the component “DisplayButton”
import React, {Component, PropTypes} from 'react';
import {createContainer} from 'meteor/react-meteor-data';
class DisplayButton extends Component {
render() {
return(
<button type="button" className="toggleDislpayButton"> Display </button>
);
}
};
DisplayButton.propTypes = {
currentUser: PropTypes.string,
displayStatus: PropTypes.bool,
};
export default createContainer(() => {
return {
currentUser: Meteor.userId(),
};
}, DisplayButton);
The button itself is rendered correctly. However, I don’t see any output on console after I click the button. What is wrong with the code. BTW, I am using Safari as well as Chrome and it doesn’t work in either of the two browsers.
Thanks
Sudheer