Skip to content

Instantly share code, notes, and snippets.

@tvorogme
Created June 24, 2018 16:01
Show Gist options
  • Save tvorogme/ddc9a3fcb5371ee3442dbdf9ff518475 to your computer and use it in GitHub Desktop.
Save tvorogme/ddc9a3fcb5371ee3442dbdf9ff518475 to your computer and use it in GitHub Desktop.
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;
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();
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