redux

redux reselect is returning a function

偶尔善良 提交于 2020-04-18 12:52:30
问题 For some strange weird reason my reselect selector is returning this function : ƒ () { if (!areArgumentsShallowlyEqual(equalityCheck, lastArgs, arguments)) { // apply arguments instead of spreading for performance. lastResult = func.apply(null, arguments); } I do not understand why it is doing this. It is supposed to return some JSON which I can use to map in my mapToProps . My redux mapping is simple enough and looks like this : const mapStateToProps = (state) => { return { initialValues:

redux reselect is returning a function

淺唱寂寞╮ 提交于 2020-04-18 12:51:32
问题 For some strange weird reason my reselect selector is returning this function : ƒ () { if (!areArgumentsShallowlyEqual(equalityCheck, lastArgs, arguments)) { // apply arguments instead of spreading for performance. lastResult = func.apply(null, arguments); } I do not understand why it is doing this. It is supposed to return some JSON which I can use to map in my mapToProps . My redux mapping is simple enough and looks like this : const mapStateToProps = (state) => { return { initialValues:

implement logout using Redux+TypeScript

一世执手 提交于 2020-04-18 05:49:41
问题 I have a login page, which redirects to a private /panel page if the login is successful and an accessToken is returned. I'm using Redux store to check for the token in the privateRoute component. Problems I'm facing: I want to implement logout from the /panel page using the exit icon. If I try to add another reducer in the combined reducer, I get TypeScript errors. What would be the best way to implement logout from the exit icon? Should I use the same tokenReducer add a LOGOUT case in the

React dom not updating with Redux store

老子叫甜甜 提交于 2020-04-18 05:36:43
问题 I'm new to react-redux and I'm having an issue with a web-app I'm developing. The app should have a user log-in functionality, it should be able to fetch and display a list of games from a database api I made, and it should be able to display information for a specific game from that list when it's clicked. I have the user log-in functionality working perfectly, but the game list and specific game details don't initially display in the browser. If I look in the redux devtools, the action is

React dom not updating with Redux store

会有一股神秘感。 提交于 2020-04-18 05:36:39
问题 I'm new to react-redux and I'm having an issue with a web-app I'm developing. The app should have a user log-in functionality, it should be able to fetch and display a list of games from a database api I made, and it should be able to display information for a specific game from that list when it's clicked. I have the user log-in functionality working perfectly, but the game list and specific game details don't initially display in the browser. If I look in the redux devtools, the action is

Is namespacing own-props separately from state-props a useful pattern?

ε祈祈猫儿з 提交于 2020-04-17 22:41:40
问题 Is the following pattern of namespacing state-provided props and parent-provided props a useful pattern? interface OwnProps { //The type for the props provided by the parent component } function mapDispatch(dispatch: Dispatch<any>) { return {dispatch}; } function mapState(state: RootState, ownProps: OwnProps) { return { o: {...ownProps}, // ownProps are namespaced onto o. s: { // stateProps are namespaced onto s. apiInReach: state.dev.apiInReach, } }; } //// ... export default connect(

Is namespacing own-props separately from state-props a useful pattern?

痞子三分冷 提交于 2020-04-17 22:41:34
问题 Is the following pattern of namespacing state-provided props and parent-provided props a useful pattern? interface OwnProps { //The type for the props provided by the parent component } function mapDispatch(dispatch: Dispatch<any>) { return {dispatch}; } function mapState(state: RootState, ownProps: OwnProps) { return { o: {...ownProps}, // ownProps are namespaced onto o. s: { // stateProps are namespaced onto s. apiInReach: state.dev.apiInReach, } }; } //// ... export default connect(

React-Redux: Post action fails with a 500 error

喜欢而已 提交于 2020-04-17 22:39:28
问题 I'm trying to insert data in my the DB using react and redux. Usign postman or cocoaRestClient to try the api call I pass data like form-data, so I think that I need to pass form-data to. I have created this file for the form: Form.js //..... this.state = { newMeeting:{ meeting: {} }, //.... handleChange = (e) => { let newMeeting = this.state.newMeeting; newMeeting.meeting[e.target.name] = e.target.value; this.setState({ newMeeting }); }; handleSubmit(event) { event.preventDefault(); console

Typescript: indexed access operator returns type unknown

我是研究僧i 提交于 2020-04-17 21:49:46
问题 follow up to this question. It's possible to extract all possible types from a TS interface using indexed access operators. In my case, I'm working w/ a large interface generated from a redux store/state. I tried the following: RootState[keyof RootState] but my resulted type is unfortunately of type unknown. The RootState interface is exported from the store like this: export type RootState = ReturnType<typeof combineReducers({allMyReducers: ... ,... ,...})>; I know that keyof RootState is a

Usage of React Redux in Modal

偶尔善良 提交于 2020-04-14 05:57:07
问题 I am learning Redux in React. I am using Redux in React for Modal development. My code is like below render() { return ( <Modal id="addressModal" open={this.props.controlModal} onClose={this.props.action}> <Provider store={store}> {this.props.addresObj ? ( <Modal.Header>Address Details</Modal.Header> ) : ( <Modal.Header>Insert Address</Modal.Header> )} <Modal.Content> <ModalElement update={this.update} element={this.props.addresObj} errors = {this.state.errors} update_state_photo={this.update