Created
June 5, 2017 16:45
-
-
Save furkankadioglu/e3b87445efffb341006afcd89992cd5d to your computer and use it in GitHub Desktop.
React - Redux Örneği
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { Component } from 'react'; | |
import { connect } from "react-redux"; | |
import axios from 'axios'; | |
import store from './store.js'; | |
import Switcher from './components/Switcher'; | |
import './components/Switcher.css'; | |
import LoginForm from './components/LoginForm'; | |
import './App.css'; | |
class App extends Component { | |
constructor(props) { | |
super(props); | |
this.state = { trackingStatus: true, authStatus: store.authStatus }; | |
this.trackingStatusUpdate = this.trackingStatusUpdate.bind(this); | |
} | |
trackingStatusUpdate(data) | |
{ | |
this.setState({trackingStatus: data}); | |
} | |
tryLogIn(values) { | |
console.log(values.email); | |
} | |
render() { | |
const { informations } = this.props; | |
console.log(informations); | |
let content; | |
if(store.authStatus) | |
{ | |
content = ( | |
<Switcher trackingStatus={this.state.trackingStatus} trackingStatusUpdate={this.trackingStatusUpdate} /> | |
); | |
} | |
else | |
{ | |
content = ( | |
<LoginForm onSubmit={this.tryLogIn} /> | |
); | |
} | |
return ( | |
<div className="App"> | |
{content} | |
</div> | |
); | |
} | |
} | |
//export default App; | |
export default connect(store => ({ | |
tracker: store.informations | |
}))(App) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment