From 8ae2d912e25aca408f42409f4e9c02290a7ebfd9 Mon Sep 17 00:00:00 2001 From: Yusuf YILDIZ Date: Tue, 2 Jun 2020 19:17:47 +0300 Subject: Rewrite Card.js with hooks (#1) --- src/components/Card.js | 80 +++++++++++++++++++++----------------------------- 1 file changed, 33 insertions(+), 47 deletions(-) (limited to 'src') diff --git a/src/components/Card.js b/src/components/Card.js index fb11834..7b615ea 100644 --- a/src/components/Card.js +++ b/src/components/Card.js @@ -1,56 +1,42 @@ -import React from 'react'; +import React, { useState, useEffect } from 'react'; import QRCode from 'qrcode.react'; import './style.css'; -class Card extends React.Component { - constructor(props) { - super(props); - this.state = {ssid: '', password: '', qrvalue: ''}; - this.handleSSIDChange = this.handleSSIDChange.bind(this); - this.handlePasswordChange= this.handlePasswordChange.bind(this); - } - - handleSSIDChange(event) { - this.setState({ssid: event.target.value}, () => this.generateqr()); - } - - handlePasswordChange(event) { - this.setState({password: event.target.value}, () => this.generateqr()); - } - - generateqr() { - const qrcode = `WIFI:T:WPA;S:${this.state.ssid};P:${this.state.password};;` - this.setState({qrvalue: qrcode}); - } - - render() { - return ( -
- +
+
- ) - } +
+ ) } export default Card; -- cgit v1.2.3