I have a button component that I wish to re-use in reactJs, I want multiple of the same component to be rendered but using different styles and to use a different style when the button is pressed and also mouse HoverOver
The button component is: -
import React, { Component } from 'react';
//import './Buttons.css'
const buttons = (props) => {
return (
<div className="">
<button id="buttons" class="-"> {props.name}</button>
</div>
);
}
export default buttons;
The main App component holds a state which then the state displays the name of the Button, which I am sure there is a better way of doing this.
Also I have made multiple of a button component and I can apply css styles that way but I am sure this is not the correct way.
class App extends Component {
state = {
name: [
{ button: 'Login' },
{ buttonTwo: 'Sign Up' },
{ buttons: 'Login' }
],
}
render() {
const style = {
backgroundColor: 'blue',
font: 'inherit',
border: '1px solid red',
padding: '8px',
};
var pressed = true
function toggle() {
pressed = !pressed
//When pressed Styles change
}
return (
<div className="App">
{/* <Right /> Temp Disabled*/}
<span><Button pressed={pressed} defaultPressed={true} pressedStyle={{color: 'blue'}}
name={this.state.name[0].button} /></span>
<span><Button name={this.state.name[1].buttonTwo} /></span>
</div>
);
}
}
export default App;
I eventually aim to create a Log in section so these buttons will be part of that.