So I have made a Dice Game π
It have 3 Compnent
App
Rolldice
Die
Die Component Consists of a Die which is rendered on the type of props passed.
In the Rolldice Component we Have 2 Die and a Button.
Whenever we click the button it will call a Function that Randomly give the value and change the values of state and then I pass the state as a props in the Die Component.
Code link π
https://github.com/Developer-io-web/Dice-Excercise
Things learnt by Doing This Project β
-
How to use the Font-awesome Icons in your React Project
To start using them we 1st have to install some packages.
npm i --save @fortawesome/fontawesome-svg-core npm install --save @fortawesome/free-solid-svg-icons npm install --save @fortawesome/react-fontawesome
Then u have to Import them into each
Component
.
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome' import { <icon-name> } from '@fortawesome/free-solid-svg-icons' import { <icon-name> } from '@fortawesome/free-brands-svg-icons'
U can use them like this π
<FontAwesomeIcon icon="<icon-name>" />
-
Method which calls the function after a particular time.
setTimeout
: calls a function once after a particularized delay.setInterval
: calls a function repeatedly, beginning after some time, then repeating continuously at the given interval.
I actually know about them earlier but doesnβt know the difference about them.
Syntax:
**SetTimeout**
setTimeout(()=>{ console.log('Repeat once after 1 second.') },1000);
setInterval
setInterval(()=>{ console.log('Repeat after every one minute'); },)