“Converta classe para componente funcional online” Respostas de código

Converta classe para componente funcional online

class Question extends React.Component {
  constructor(props) {
    super(props);
    this.handleChange = this.handleChange.bind(this);
  }
  handleChange(e) {
    e.preventDefault();
    this.props.onChoiceChange(e.target.value);
  }
  render() {
      const question = this.props.question;
      return(
        <div className="well">
          <h3>{question.text}</h3>
          <hr />
          <ul className="list-group">
            {
              question.choices.map(choice => {
                return (
                  <li className="list-group-item" key={choice.id}>
                    {choice.id} <input type="radio" onChange={this.handleChange} name={question.id} value={choice.id} /> {choice.text}
                  </li>
                )
              })
            }
          </ul>
        </div>
      )
  }
}
Annoying Antelope

Converta classe para componente funcional online

export default class Sweetalertdemo extends Component {  
  
  constructor() {  
    super();  
    this.HandleClick = this.HandleClick.bind(this);  
  }  
  
  HandleClick() {  
    Swal.fire({  
      title: 'Success',  
      type: 'success',  
      text: 'Your work has been saved.',  
    });  
  }  
  HandleClick1() {  
    Swal.fire({  
      title: 'Are you sure?',  
      text: 'User will have Admin Privileges',  
      icon: 'warning',  
      showCancelButton: true,  
      confirmButtonColor: '#3085d6',  
      cancelButtonColor: '#d33',  
      confirmButtonText: 'Yes!'  
    });  
  }  
  HandleClick12() {  
    Swal.fire({  
      icon: 'error',  
      title: 'Oops...',  
      text: 'Something went wrong!',  
      footer: '<a href>Why do I have this issue?</a>'  
    });  
  }  
  HandleClicktop() {  
    Swal.fire({  
      position: 'top-end',  
      icon: 'success',  
      title: 'Your work has been saved',  
      showConfirmButton: false,  
      timer: 1500  
    });  
  }  
  HandleClickAutoclose() {  
    let timerInterval  
    Swal.fire({  
      title: 'Auto close alert!',  
      html: 'I will close in <b></b> milliseconds.',  
      timer: 1000,  
      timerProgressBar: true,  
      onBeforeOpen: () => {  
        Swal.showLoading()  
        timerInterval = setInterval(() => {  
          const content = Swal.getContent()  
          if (content) {  
            const b = content.querySelector('b')  
            if (b) {  
              b.textContent = Swal.getTimerLeft()  
            }  
          }  
        }, 100)  
      },  
      onClose: () => {  
        clearInterval(timerInterval)  
      }  
    }).then((result) => {  
      if (result.dismiss === Swal.DismissReason.timer) {  
        console.log('I was closed by the timer')  
      }  
    })  
  }  
  
Satish Mewada

Converta classe para componente funcional online

import React, { Component } from 'react'

export class MultipleCheckBox extends Component {

    state={
        Colornames:{
            first:false,
            second:false,
            third:false
        }
    }
    checkBoxClick = (e) => {
        let {name, checked} = e.target;
        this.setState((e) => {
            let selectedSport=e.Colornames;
            return selectedSport[name]=checked;
        })
    }
    
    render() {

        // let displaySports=Object.keys(this.state.Colornames).filter((x)=> this.state.Colornames[x])
        return (
            <div>
                <div>
                    <h1>
                        gfghfh
                    </h1>
                    <label htmlFor="foo">first</label>
                    <input type="checkbox" name="first" id="foo" onChange={this.checkBoxClick}/>
                    <label htmlFor="bar">second</label>
                    <input type="checkbox" name="second" id="bar" onChange={this.checkBoxClick}/>
                    <label htmlFor="coo">third</label>
                    <input type="checkbox" name="third" id="coo" onChange={this.checkBoxClick}/>
                    <hr/>
                    {/* <div style={{backgroundColor: "black", color: "cyan"}}>
                        {displaySports+" "}
                    </div> */}
                </div>
            </div>
        )
    }
}

export default MultipleCheckBox
Bewildered Bug

Converta classe para componente funcional online

import React, { Component } from "react";
import { InputGroup, FormControl, Input } from "react-bootstrap";

class SimpleKeyEvent extends Component {
  constructor() {
    super();
    this.state = {
      name: "React-bootstrap key enter event"
    };
    this.onKeyUp = this.onKeyUp.bind(this);
  }

  onKeyUp(event) {
    if (event.charCode === 13) {
      this.setState({ inputValue: event.target.value });
    }
  }

  render() {
    const { inputValue } = this.state;

    return (
      <div>
        <InputGroup>
          <FormControl placeholder="First name" onKeyPress={this.onKeyUp} />
        </InputGroup>
        <hr />
        <span>Input value is : {inputValue}</span>
      </div>
    );
  }
}

export default SimpleKeyEvent;
Charming Cormorant

Respostas semelhantes a “Converta classe para componente funcional online”

Perguntas semelhantes a “Converta classe para componente funcional online”

Mais respostas relacionadas para “Converta classe para componente funcional online” em JavaScript

Procure respostas de código populares por idioma

Procurar outros idiomas de código