Last active
February 22, 2018 21:12
-
-
Save santiago/73baebd0b6b9694affde4b962c51763a to your computer and use it in GitHub Desktop.
This file contains 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 Sidebar from '../Sidebar/Sidebar'; | |
import GoogleMap from '../GoogleMaps/GoogleMap'; | |
class App extends Component { | |
render() { | |
return ( | |
<div> | |
<Sidebar /> | |
<GoogleMap /> | |
</div> | |
); | |
} | |
} | |
export default App; |
This file contains 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 { Map, InfoWindow, Marker, GoogleApiWrapper } from 'google-maps-react'; | |
export class GoogleMap extends Component { | |
state = { | |
selectedPlace: { name: 'Lugarsito' } | |
} | |
onMarkerClick = () => { | |
console.log('marker'); | |
} | |
onInfoWindowClose() { | |
console.log('info window'); | |
} | |
componentDidMount() { | |
console.log(this.props); | |
} | |
componentWillUpdate(props) { | |
console.log(props) | |
} | |
render() { | |
return ( | |
<Map | |
google={this.props.google} | |
initialCenter={{ | |
lat: 40.854885, | |
lng: -88.081807 | |
}} | |
zoom={14} | |
> | |
<Marker onClick={this.onMarkerClick} | |
name={'Current location'} /> | |
<InfoWindow onClose={this.onInfoWindowClose}> | |
<div> | |
<h1>{this.state.selectedPlace.name}</h1> | |
</div> | |
</InfoWindow> | |
</Map> | |
); | |
} | |
} | |
export default GoogleApiWrapper({ | |
apiKey: 'AIzaSyCkZpRQTgpvT7DN5sbth6-GRQncJ9nSiKI', | |
version: '3.30', | |
libraries: ['geometry', 'drawing', 'places'] | |
})(GoogleMap) |
This file contains 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
export const initialState = { | |
user: { | |
isLogging: 0, | |
isLogout: 0, | |
isLogged: 0 | |
}, | |
data: { | |
projects: [] | |
} | |
}; | |
const reducers = { | |
user: function(state = initialState.user, action) { | |
switch (action.type) { | |
case 'LOGGING': | |
return { isLogged: 0, isLogging: 1, isLogout: 0 }; | |
case 'LOGGED': | |
return { isLogged: 1, isLogging: 0, isLogout: 0 }; | |
case 'LOGOUT': | |
return { isLogged: 0, isLogging: 0, isLogout: 1 }; | |
case 'WILL_LOGOUT': | |
return { isLogged: 0, isLogging: 0, isLogout: 0, willLogout: 1 }; | |
case 'LOGOFF': | |
return { isLogged: 0, isLogging: 0, isLogout: 0 }; | |
default: | |
return state; | |
} | |
}, | |
data: function (state = initialState.data, action) { | |
switch (action.type) { | |
default: | |
return state; | |
} | |
} | |
} | |
export default reducers; |
This file contains 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 { applyMiddleware, createStore, combineReducers } from 'redux'; | |
import logger from 'redux-logger'; | |
import thunk from 'redux-thunk'; | |
import rootReducer, { initialState } from '../reducers/root'; | |
export default function configStore(history) { | |
let middleware = [thunk]; | |
// if (__DEV__) { | |
middleware = [...middleware, logger]; | |
// } | |
const reducer = combineReducers({ ...rootReducer }); | |
return createStore( | |
rootReducer, | |
initialState, | |
applyMiddleware(...middleware) | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment