redux-form

TypeScript, redux-form and connect

我们两清 提交于 2019-12-04 10:02:43
First of all, I'm very new to TS, React & Redux, so sorry if this is an obvious question. I'm trying to modify this example to get a form to load some information. It's using redux-form . I'm trying to figure out how to call connect and redux-form at the same time in the export of the component. Right now it's looking like this: class UserForm extends React.Component<IUserProps, void> { .. } export default ReduxForm.reduxForm({ form: 'user', fields: [ 'userName', 'password', 'firstName', 'lastName', 'email' ], validate: UserForm.validate, })(UserForm); The examples I've seen without TS look

redux saga and history.push

落花浮王杯 提交于 2019-12-04 08:36:17
Backgrond: I am creating a Login component. saga.js is composed by 3 functions 1. rootSaga . It will execute the list of sagas inside 2. watchSubmitBtn . It will watch the click on the submit button and dispatch an action. 3. shootApiTokenAuth will receive dispatched action and process axios.post the return value is promise object In action: Backend returns 400 to the React . This case no problem I can read the payload and display in the render() easily. But when 200 is returned. I need to let user go to the url /companies . Attempt: I had tried put this.props.history.push('/companies'); in

How to stop redux-form's “form” state from auto-rehydrated by redux-persit

烂漫一生 提交于 2019-12-04 07:28:14
I'm using redux-form and it provides a built-in reducer, called "formReducer" that need to be registered with the combined reducers to manage the form state with redux's store. I'm also using redux-persist to persist the redux store. The problem raised when I don't want to have my form automatically re-populate the data entered by the user on page reloading or page refreshing. In a normal reducer written by my own, I can simply add an switch case for action of type "REHYDRATE" (dispatched by redux-persit) to prevent the state slice from auto-rehydrating by just returning its initial state or

Does redux-form field value can hold object instead of just a string?

会有一股神秘感。 提交于 2019-12-04 06:40:25
Does redux-form field value can hold object instead of just a string? Consider following example class SelectQuestions extends Component{ render(){ const {fields:{question1,question2},handleSubmit}=this.props; return <div> <form onSubmit={handleSumbit(this.handleFunction.bind(this))}> <SelectQuestion {...question1}/> <SelectQuestion {...question1}/> <button type="submit" className="btn btn-default">Submit</button> </form> </div> } } class SelectQuestion extends Component{ render (){ <select></select> } } 'SelectQuestion' takes array of Questions, each Question has question id and question name

How to re-trigger validations manually in ReduxForm?

和自甴很熟 提交于 2019-12-03 23:53:15
问题 I like to re-trigger validations after the form has mounted. Let's assume I like to run the validations each time I click a button named 'validate inputs'. How to do this? Related questions: How to run validation on a slice of a redux-form FieldArray state Is there a way in Redux Forms to make a form validate from code? 回答1: Manual redux-form validation is an oft requested feature, that does not seem to be provided at the moment. My personal workaround is to trigger this.props.change('

How to handle redux-form/CHANGE in reducer

柔情痞子 提交于 2019-12-03 20:12:37
What is the recommended way to handle redux-form/CHANGE actions being dispatched by redux-form? I have my own reducer managing the state of this form but I'm not sure if it's best to do the following: export default reducer (state = initialState, action) { case 'redux-form/CHANGE': // return modified state } One problem I see is that this reducer would receive every redux-form/CHANGE action. Additionally as far as I can tell ActionTypes.js isn't exported in a way for me to import it so I feel as though this may not be best practice. You can definitely use redux-form action creators. You just

Multiple checkbox in redux-form

∥☆過路亽.° 提交于 2019-12-03 17:36:39
问题 I would like to ask, here's the scenario. I have this multiple checkbox but my problem is whenever I tick one checkbox, all of the 4 checkboxes are selected. And also why is it the value of checkbox is just true or false.Here's my checkbox: <div className="checkbox"> <label><Field name="investor_stage" component="input" type="checkbox" value="Seed" /> Seed</label> </div> <div className="checkbox"> <label><Field name="investor_stage" component="input" type="checkbox" value="Early Stages" />

Redux Form Typescript Pass Custom Props

自闭症网瘾萝莉.ら 提交于 2019-12-03 15:52:39
I am trying to pass custom props to my component which is decorated with reduxForm . Also I am very new in Typescript. The first problem is that I can't wrap the decorated component with connect: export default connect(mapStateToProps)( reduxForm({ form: 'myform' })(MyComponent) ) The error: Error:(89, 5) TS2345:Argument of type 'DecoratedComponentClass<any, Partial<ConfigProps<any, {}>>>' is not assignable to parameter of type 'ComponentType<{ addressValue: any; isDeliveryAddress: any; customerTypeValue: any; } & DispatchPr...'. Type 'DecoratedComponentClass<any, Partial<ConfigProps<any, {}>>

How to enable file upload on React's Material UI simple input?

微笑、不失礼 提交于 2019-12-03 10:30:41
问题 I am creating a simple form to upload file using electron-react-boilerplate with redux form & material ui. The problem is that I do not know how to create input file field because material ui does not support upload file input. Any ideas on how to achieve this? 回答1: Another >=v1.0 solution that makes more sense to me structurally than @galki's solution. RaisedButton is deprecated in >=v1.0. I cannot find more information on containerElement (it may have been undocumented?) but the current API

Redux Form - initialValues not updating with state

冷暖自知 提交于 2019-12-03 08:40:01
问题 I am having some issues with setting the inital form field values using redux-form. I am using redux-form v6.0.0-rc.3 and react v15.3.0. So here's my issue, I have a grid of users and when a user row is clicked on, I am navigating to an edit users page and including the users id in the url. Then on the edit users page, I am grabbing the id and calling fetchUser(this.props.params.id) which is an action creator that returns this.state.users. I am then attempting to set the forms inital values