Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import React, { Component } from 'react'
- import Homepage from './HomePage'
- import LogOut from './LogOut'
- class Parent extends Component {
- constructor(props) {
- super(props)
- this.state = {
- count : 0,
- isLoggedIn: false
- }
- }
- increase = () => {
- this.setState({
- count: this.state.count + 1
- })
- }
- decrease = () => {
- if(this.state.count > 0){
- this.setState({
- count: this.state.count - 1
- })
- }else{
- return
- }
- }
- check = () => {
- const element = this.state.isLoggedIn ? <Homepage/> : <LogOut/>
- return element
- }
- render() {
- return (
- <div>
- <h1>Count: {this.state.count}</h1>
- <button onClick = {this.check}>Click me</button>
- </div>
- )
- }
- }
- export default Parent
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement