Created
June 24, 2018 16:01
-
-
Save tvorogme/ddc9a3fcb5371ee3442dbdf9ff518475 to your computer and use it in GitHub Desktop.
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 {updateLol} from './Redux' | |
class App extends Component { | |
constructor(props) { | |
super(props); | |
const a = updateLol("lolkekcheburek"); | |
console.log(a); | |
this.props.dispatch(a) | |
} | |
render() { | |
console.log(updateLol("TEST")); | |
return <h1>{this.props.lol}</h1> | |
} | |
} | |
const mapStateToProps = state => ({lol: state.lol}); | |
const mapDispatchToProps = dispatch => ({dispatch: dispatch}); | |
App = connect(mapStateToProps, mapDispatchToProps)(App); | |
export default App; |
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 from 'react'; | |
import ReactDOM from 'react-dom'; | |
import './index.css'; | |
import App from './App'; | |
import registerServiceWorker from './registerServiceWorker'; | |
import {Provider} from 'react-redux'; | |
import {store} from './Redux' | |
ReactDOM.render(<Provider store={store}><App/></Provider>, | |
document.getElementById('root')); | |
registerServiceWorker(); |
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 {createStore, combineReducers} from 'redux' | |
const MYFIRST_ACTION = "MYFIRST_ACTION"; | |
export const updateLol = data => ({ | |
type: MYFIRST_ACTION, | |
lol: data | |
}); | |
const myfirstReducer = (state, action) => { | |
return action.type === MYFIRST_ACTION ? action.lol : ""; | |
}; | |
const reducers = combineReducers({ | |
lol: myfirstReducer, | |
}); | |
export const store = createStore(reducers); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment