1- import React , { FunctionComponent } from 'react' ;
1+ import React , { FunctionComponent , useEffect , useState } from 'react' ;
2+ import { useLocation } from 'react-router-dom' ;
23import styled from 'styled-components' ;
34import { NotificationParams } from '../shared/interfaces' ;
45import Notification from './Notification' ;
56// store
67import { observer } from 'mobx-react' ;
78import { useStore } from '../store' ;
9+ import { autorun , reaction } from 'mobx' ;
810
911const Notifications : FunctionComponent = ( ) => {
1012 const store = useStore ( ) ;
13+ const location = useLocation ( ) ;
14+ const [ isRoot , setIsRoot ] = useState ( true ) ;
15+
16+ useEffect ( ( ) => {
17+ setIsRoot ( location . pathname === '/' ) ;
18+ } , [ location ] ) ;
1119
1220 const deleteNotification = ( id : string ) =>
1321 store . notifications . splice (
@@ -18,7 +26,7 @@ const Notifications: FunctionComponent = () => {
1826 if ( store . notifications . length === 0 ) return null ;
1927
2028 return (
21- < NotificationsContainer >
29+ < NotificationsContainer isRoot = { isRoot } >
2230 { store . notifications . map ( ( data : NotificationParams , key ) => (
2331 < Notification
2432 key = { key }
@@ -34,7 +42,7 @@ const NotificationsContainer = styled.div`
3442 display: flex;
3543 flex-direction: column-reverse;
3644 position: absolute;
37- bottom: 39px ;
45+ bottom: ${ ( props ) => ( props . isRoot ? 39 : 0 ) } px ;
3846 z-index: 11;
3947 padding: 10px;
4048 width: 100%;
0 commit comments