react-redux

Failed to parse “4.” to 4

青春壹個敷衍的年華 提交于 2020-01-03 02:50:06
问题 I am working in React-redux and creating a number type field. The event.target.value returns a string, since it is number type editor it must return value as number so I parse the value to number. The problem comes when I try to enter 4.5 . Firstly, when I type 4 it will get parsed into 4 (sting to number). But when the . entered the number 4. get parse into 4 , so I just failed to enter the floating point values. let onChangeText = (value)=> { fieldProps.onChange(parseFloat(value)); } If I

React: Dispatch not firing on route change

眉间皱痕 提交于 2020-01-03 02:31:28
问题 I have several routes that use the same controller: <Route component={Search} path='/accommodation(/:state)(/:region)(/:area)' /> and when the route is changed I call the api function from within the component: componentWillReceiveProps = (nextProps) => { if (this.props.params != nextProps.params) { loadSearch(nextProps.params); } } which is an action as follows: export function loadSearch (params) { return (dispatch) => { return dispatch( loadDestination(params) ).then(() => { return

how to avoid or disable autoComplete in text input for Redux form?

不想你离开。 提交于 2020-01-02 15:27:27
问题 i am using ReactJS and ReduxJS to construct my application . I created my form using Redux-Form and there are many text input and for one of them ,i am using onkeyDown event to increase and decrease number in my text so when i click up arrow or enter first digit the text is auto completed with previous date entered(history) that disturb when i click another up arrow [Hint] I tried AutoComplete=off and did not work 回答1: You just have the attribute cased incorrectly. You can use the following 3

Is it possible to connect non component Class to redux store?

拟墨画扇 提交于 2020-01-02 00:49:28
问题 So I am using a react-redux boilerplate that has an ApiClient helper. It looks like this: export default class ApiClient { constructor(req) { /* eslint-disable no-return-assign */ methods.forEach((method) => this[method] = (path, withCredentials, { params, data } = {}) => new Promise((resolve, reject) => { const request = superagent[method](formatUrl(path)) if (withCredentials) { console.log('first of all, its true') console.log(this) } if (params) { request.query(params) } if (__SERVER__ &&

Going back from a redirect tag - React Router

人走茶凉 提交于 2020-01-01 14:34:30
问题 Currently, I created a search bar and I have my search bar linked to my search results like this: render() { if (this.props.itemsFetchSuccess) { return ( <Redirect to={{ pathname: '/search', search: `?item-name=${this.props.searchQuery}` }} /> ); as part of the render component of my search bar. GOOGLE CHROME MAIN -> MAIN LANDING -> SEARCH RESULTS. But I'm suspecting that because I used a redirect tag in React-Router v4, it's not adding it to the browser history stack. If I press back on a

Has anyone came across this error in TS with redux dev tools? “Property '__REDUX_DEVTOOLS_EXTENSION_COMPOSE__' does not exist on type 'Window'.”?

风流意气都作罢 提交于 2020-01-01 07:39:58
问题 I'm getting this error on my index.tsx. Property ' REDUX_DEVTOOLS_EXTENSION_COMPOSE ' does not exist on type 'Window'. Here is my index.tsx code: import * as React from 'react'; import * as ReactDOM from 'react-dom'; import App from './App'; import './index.css'; import registerServiceWorker from './registerServiceWorker'; import { Provider } from 'react-redux'; import { createStore, compose, applyMiddleware } from 'redux'; import rootReducer from './store/reducers'; import thunk from 'redux

How and where to save the whole redux store using AsyncStorage

心不动则不痛 提交于 2020-01-01 04:16:05
问题 I was wondering if I have to do something like this to save the whole store of my app using AsyncStorage in my react-native app and check if it exists when the app is starting. var store; _loadInitialState = async () => { try { var value = await AsyncStorage.getItem(STORAGE_KEY); if (value !== null){ store = value; console.log('Recovered selection from disk: ' + value); } else { store = configureStore({}); console.log('Initialized with no selection on disk.'); } } catch (error) { console.log(

Redirect using react-router in redux middleware

你说的曾经没有我的故事 提交于 2020-01-01 03:39:26
问题 I've created a middleware that checks if a request returns an invalid access response. If the status is a 401, I want to redirect the user to the login page Here's the middleware code import React from 'react'; import { push, replace } from 'react-router-redux'; const auth_check = ({ getState }) => { return (next) => (action) => { if(action.payload != undefined && action.payload.status==401){ push('login'); console.log('session expired'); } // Call the next dispatch method in the middleware

Strongly typing the react-redux connect with typescript

蓝咒 提交于 2019-12-31 13:00:10
问题 I am getting an error trying to type the parameters for my react component. I would like to stronly type what properties will be on the props and state of a component, but when I do so using Redux, I am getting an error when I pass mapStateToProps to the connect function. This is the component code: import React, { Component } from 'react'; import ReactDOM from 'react-dom'; import { bindActionCreators } from 'redux'; import { connect } from 'react-redux'; import FileExplorer from '..

Avoid re-rendering a big list of items with react-redux

回眸只為那壹抹淺笑 提交于 2019-12-31 08:39:45
问题 I am using redux with react and typescript for my application. I am working with many items used at different places of my app. My state looks like this: { items: {42: {}, 53: {}, ... }, //A large dictionary of items itemPage1: { itemsId: [ 42, 34, 4 ], ... }, itemPage2: { ... }, ... } The user can modify some attributes of the items dispatching some actions. When this happen I need to redraw the components that have been modified in each pages. The issue is that my items are quite big and I