Im having trouble with the following code:
My compnent:
class Landing extends Component {
state = {
loginMethod: '',
tournamentCode: -1,
}
}
My Const:
const Code = () => (
<div className= style={{marginTop: 20}}>
<input
className=
style={{lineHeight: 1, height: 30, border:0, paddingLeft: 5}}
placeholder=Tournament Code
onChange={e => this.setState({tournamentCode: e.target.value})} />
<Link to=/App>
<button className= style={{marginLeft: 10, border: 0, outline:
'none', background: '#efefef', height: 30, width: 80}}> Enter </button>
</Link>
</div>
)
Both of there are in the same Landing.js
file.
I know my problem is that i try to do this.setState
outside the Landing class.
Are there any solutions for this problem? Or is there a better way i should program this?
I've also read some things about redux and contexts in react. Which of these is my best way to go? Or are there more easy solutions?