From 29798cb87dd2fab81364b4b234e7c02a913fb1ab Mon Sep 17 00:00:00 2001 From: asabeneh Date: Sun, 18 Oct 2020 04:08:06 +0300 Subject: [PATCH] day 18 has been added --- 17_React_Router/17_react_router.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/17_React_Router/17_react_router.md b/17_React_Router/17_react_router.md index 1afcd0d..ef658da 100644 --- a/17_React_Router/17_react_router.md +++ b/17_React_Router/17_react_router.md @@ -26,6 +26,7 @@ - [NavLink](#navlink) - [Nested Routing](#nested-routing) - [Redirect](#redirect) + - [Prompt](#prompt) - [Exercises](#exercises) - [Exercises: Level 1](#exercises-level-1) - [Exercises: Level 2](#exercises-level-2) @@ -1102,6 +1103,8 @@ const rootElement = document.getElementById('root') ReactDOM.render(, rootElement) ``` +## Prompt + Sometimes when a user try to leave a page we may like to inform that he has unfinished task. In order to do that we can use the Prompt component. The Prompt component takes two props which are when and message(). Let's implement this in the previous code. In the following code a Prompt has been implemented without when therefore it will check all the routes. @@ -1404,7 +1407,7 @@ const rootElement = document.getElementById('root') ReactDOM.render(, rootElement) ``` -Instead of without condition, let's inform the user if he really wants to log out. +Instead of without condition, let's inform the user if he really wants to log out by adding checking some condition using a call back function inside the message. ```js import React, { Component } from 'react'