Skip to content

Instantly share code, notes, and snippets.

@yashnirmal
yashnirmal / index.js
Last active June 19, 2023 12:16
Problem : Make a component that asks the user to log in if he don’t within 10 seconds of landing on the page
```
Inside the useEffect, a timeout is set using setTimeout.
After 10 seconds, the setShow function is called to update the show state to true.
The useEffect hook also returns a cleanup function, which is called when the component is unmounted. In this case, it clears the timeout by calling clearTimeout(tId).
We also have handleLogin function which is defined to handle the login action.
It logs "Timeout cleared" to the console, sets the loggedIn state to true, and clears the timeout by calling clearTimeout(tId).
```
import { useEffect, useState } from "react";
@yashnirmal
yashnirmal / Multi_Lingual_Website.html
Last active April 1, 2023 18:23
Making Multilingual Websites using Google Translate
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>My Simple Website</title>
<!-- Loading the Google Translate API -->
<script type="text/javascript" defer src="https://translate.google.com/translate_a/element.js?cb=googleTranslateElementInit"></script>
<script defer type="text/javascript">