34 lines
878 B
JavaScript
34 lines
878 B
JavaScript
import React, { Component } from 'react';
|
|
|
|
import './css/Button.css';
|
|
|
|
|
|
class Button extends Component {
|
|
// Multiple onClick functions
|
|
onClick = () => {
|
|
console.log(this.props.onClick);
|
|
|
|
if (this.props.onClick !== null
|
|
&& this.props.onClick !== undefined) {
|
|
if (Array.isArray(this.props.onClick)) {
|
|
this.props.onClick.forEach(func => {
|
|
func();
|
|
});
|
|
} else {
|
|
console.log("Error when parsing Button onClick functions.");
|
|
}
|
|
} else {
|
|
console.log("Error when parsing Button onClick functions.");
|
|
}
|
|
}
|
|
|
|
render() {
|
|
return (
|
|
<button className={this.props.className} onClick={this.onClick}>
|
|
{this.props.children}
|
|
</button>
|
|
);
|
|
}
|
|
}
|
|
|
|
export default Button; |