Skip to content

Instantly share code, notes, and snippets.

@jenicarvalho
Created March 9, 2021 00:02
Show Gist options
  • Select an option

  • Save jenicarvalho/c2cabc111dfced088db4d736018ece85 to your computer and use it in GitHub Desktop.

Select an option

Save jenicarvalho/c2cabc111dfced088db4d736018ece85 to your computer and use it in GitHub Desktop.
import { Component } from 'react'

class MeuComponent extends Component<any> {

  state = {
    nome: 'Jeniffer',
    idade: 20,
    casado: false
  } 

  mudarNome = () => {
    this.setState(
      { nome: 'Lara Santos', idade: 28, casado: false }
    ) 
  }

  render() {
    return (
      <div>
        {
          this.state.casado ? <p>é casado</p> : <p>não é casado</p>
        }
        <p>olar, {this.state.nome}</p>
        <button onClick={this.mudarNome}>Clique</button>
      </div>
    )
  }
}

export default MeuComponent
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment