-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SFCCounterConnectedExtended does not work in examples #25
Comments
Hi @29er export interface SFCCounterConnectedExtendedProps {
initialCount: number,
}
const mapStateToProps = (state: RootState, ownProps: SFCCounterConnectedExtendedProps) => ({
// if redux store value is undefined, use initialCount to initialize
count: state.counters.sfcCounter || ownProps.initialCount,
});
export const SFCCounterConnectedExtended = connect(mapStateToProps, {
onIncrement: actionCreators.incrementSfc,
})(SFCCounter); I know that's not really a precise answer to your question but for this particular example using Maybe you can provide a different example for your specific use case if it does not answer your question. |
Yep that makes perfect sense. thanks! I am just learning Typescript for the first time and this has been an excellent repo to find. At this point even the simplest things are tripping me up. So thanks : ) . I'd love to see an actual component implementation of the Todos ! |
@29er cool, I'll close the ticket. About Todos implementation, seems like a nice idea. I'll try to add it in the future. |
Thanks Piotr ,so what I don't understand, is even after I change the example , when I create the component like so
This should set the state 'count' to 10, and should be 11 on the next onIncrement, I would have thought ! Can you explain how you would fix this in your example ? Thanks ! |
@29er The problem is we do not update the store with this initial value on component mount event, we only show it as a default when the store value is 0, which is kind of naive implementation. Need to rethink this example again, give me a moment hehe :) |
@29er fixed, now it should add or subtract a initial value from state so increment will work just fine the same for initial value |
The initialCount property does not work on the SFCCounterConnectedExtended component.
the initalCount is not read into the props because you are using the SFCCounter. What would be your recommendation on fixing this, create a new component or interface ?
The text was updated successfully, but these errors were encountered: