-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp.js
More file actions
80 lines (69 loc) · 2.22 KB
/
App.js
File metadata and controls
80 lines (69 loc) · 2.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
import React, {useState} from "react";
import "./styles.css";
var color="yellow";
const emojiDictionary={
"😊":"smilling",
"🤦♂️":"disbelief",
"😔":"Sad",
"❤️🔥":"love",
"😑":"annoyance",
"😀":"grinning",
"😆":"laughting",
"😊":"blush",
"😇":"innocent",
"😋":"yum"
};
var emojisWeKnow=Object.keys(emojiDictionary); //here we convert object to array Array ["😊", "🤦♂️", "😔"]
export default function App() {
{/*const [likeCounter,setLikeCounter]=useState(0);
function likeclickhandler(){
var newLikeCounterValue=likeCounter+1; //processing
setLikeCounter(newLikeCounterValue); }//output
const [userInput,setUserInput]=useState("");
function inputChangeHandler(event){
setUserInput(event.target.value);
} */}
const [meaning,setMeaning]=useState("");//initialse meaning with white space
function emojiInputHandler(event){
var userInput=event.target.value;
var meaning=emojiDictionary[userInput]; // accessing emoji variable to get the desired meaning of the key
if(meaning===undefined){
meaning="we dont have this emoji";
}
setMeaning(meaning); //react function
}
function emojiClickHandler(emoji){
var meaning=emojiDictionary[emoji];
setMeaning(meaning);
}
{/*var shoplist=["apple","banana","pear","guava"];*/}
return (
<div className="App">
<h1 style={{backgroundColor:color}}>Let's decode emoji's meaning !!!</h1>
{/* <button onClick={likeclickhandler}>like me </button>{likeCounter} */}
<input onChange={emojiInputHandler} placeholder=" paste the emoji picture...."/>
<h2>{meaning}</h2> {/* actual output set by react using usestate */}
<h3>emojis we know</h3>
{emojisWeKnow.map(function(emoji){
return (
<span
onClick={()=>emojiClickHandler(emoji)}
style={{fontSize:"2rem", padding:"0.5rem",cursor:"pointer"}} key={emoji}>
{emoji}{" "}
</span>
);
})}
{/*}
<div className="App">
<h1>print shopping list</h1>
<ui>
{shoplist.map(items=>{
return <li>{items}</li>
})}
</ui>
</div>
*/}
</div>
);
}
//viser - view - interact - >state in event handler -> render