Skip to content

Commit

Permalink
The Route Component
Browse files Browse the repository at this point in the history
  • Loading branch information
tupkung committed Sep 2, 2017
1 parent 91ae15b commit ec9aa2a
Showing 1 changed file with 7 additions and 12 deletions.
19 changes: 7 additions & 12 deletions contacts/src/App.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import React, {Component} from 'react'
import { Route } from 'react-router-dom'
import ListContacts from './ListContacts'
import * as ContactsAPI from './utils/ContactsAPI'
import CreateContact from './CreateContact'

class App extends Component {
state = {
screen: 'list', // list, create
contacts: []
}
removeContact = (contact) => {
Expand All @@ -24,20 +24,15 @@ class App extends Component {

render() {
return (
<div>
{this.state.screen === 'list' && (
<div className="app">
<Route exact path="/" render={() => (
<ListContacts
onDeleteContact={this.removeContact}
contacts={this.state.contacts}
onNavigate={()=>{
this.setState({ screen: 'create'})
}}
onDeleteContact={this.removeContact}
contacts={this.state.contacts}
/>
)}
)}/>

{this.state.screen === 'create' && (
<CreateContact />
)}
<Route path="/create" component={CreateContact} />


</div>
Expand Down

0 comments on commit ec9aa2a

Please sign in to comment.