File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ import axios from 'axios'
33
44
55import Navbar from './components/layout/Navbar'
6+ import Alert from './components/layout/Alert'
67import Users from './components/users/Users'
78import Search from './components/users/Search'
89
@@ -11,7 +12,8 @@ import './App.css';
1112class App extends Component {
1213 state = {
1314 users : [ ] ,
14- loading : false
15+ loading : false ,
16+ alert : null
1517 }
1618
1719 async componentDidMount ( ) {
@@ -37,16 +39,28 @@ class App extends Component {
3739 loading : false
3840 } )
3941 }
42+
43+ setAlert = ( message , type ) => {
44+ this . setState ( {
45+ alert :{
46+ message : message ,
47+ type : type
48+ }
49+ } )
50+ setTimeout ( ( ) => this . setState ( { alert : null } ) , 3000 )
51+ }
4052
4153 render ( ) {
4254 return (
4355 < div >
4456 < Navbar title = "Github Finder" icon = "fab fa-github" />
4557 < div className = "container" >
58+ < Alert alert = { this . state . alert } />
4659 < Search
4760 searchUsers = { this . searchUsers }
4861 clearUsers = { this . clearUsers }
49- showClear = { this . state . users . length > 0 ? true : false } />
62+ showClear = { this . state . users . length > 0 ? true : false }
63+ setAlert = { this . setAlert } />
5064 < Users
5165 loading = { this . state . loading }
5266 users = { this . state . users } />
You can’t perform that action at this time.
0 commit comments