mapStateToProps not recalled on action
See original GitHub issueHi,
action:
import * as types from './constants.js';
export function changeLook(multipleOutFitLook) {
return {
type: types.CHANGE_LOOK,
multipleOutFitLook
};
}
reducer:
import * as types from '../actions/constants.js';
import assign from 'object-assign';
const initialState = {
multipleOutFitLook: 1
};
export default function friends(state = initialState, action) {
debugger;
switch (action.type) {
case types.CHANGE_LOOK:
const newLookNumber = action.multipleOutFitLook;
return assign({}, state, {multipleOutFitLook: 2})
default:
return state;
}
}
app
export default class App extends Component {
constructor(props) {
super(props);
}
render() {
let {productData, w3cDigitalDataJson, locale, language, dispatch} = this.props;
const actions = bindActionCreators(appAction, dispatch);
<h1 onClick={function() {
console.log(actions.changeLook(2))
}}>Hello - {this.props.look}</h1>
</section>
);
}
}
function mapStateToProps(state) {
return {
look: state.default.multipleOutFitLook
};
}
let connectApp = (typeof document !== "undefined" ? connect(mapStateToProps)(App) : App);
export default connectApp
In the app, i am trying to update multipleOutFitLook
, when I click the h1, but the function mapStateToProps
, is only called on the initial page load.
Issue Analytics
- State:
- Created 8 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Redux connected React component not updating until a GET ...
My react app uses a redux connected component to render data from backend for a project page, so I called a GET dispatch...
Read more >Connect | React Redux
Your mapStateToProps functions are expected to return an object. This object, normally referred to as stateProps , will be merged as props to ......
Read more >Using state from your Store in your views - Human Redux
Recall from the action creators chapter that bindActionCreators() takes an object of action creator functions and returns an object with all the same...
Read more >06 React Redux connect map state and dispatch - YouTube
This is a video tutorial series on React and Redux. This video covers using connecting components with the redux store using mapStateToProps ......
Read more >Async Redux, Tools - Lecture 10 - CS50 Video Player
0:12:07And if you recall, action types are just that key · 0:12:10in an action that lets us ... 0:28:07And if not, then we...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
No problem, glad to help.
@gaearon you are amazing, i am trying to get redux adopted by my team (net-a-porter.com/mrporter.com). Thank you so much.