redux-form

Enable redux-form and set focus to field

≯℡__Kan透↙ 提交于 2019-12-08 13:05:35
问题 I've got disabled form field by default and when user clicks on button Edit , it will enable the field. I also want to set focus on the field, but I don't know how. I've created ref to the field and tried some focus() function on it, but it hasn't worked. You can try it here on sandbox. 回答1: You must assign the ref to the input element instead of the Field component Add an callback to set in your parent component the reference of subcomponent input Use the reference to focus the input when

How to get value from Fields in redux-form?

允我心安 提交于 2019-12-08 11:53:05
问题 I have two fields on my component: ${adjustment}.lastYear and ${adjustment}.currentYear import React from 'react'; import { Field } from 'redux-form'; import { IconDelete, Select } from 'user-comps'; import PropTypes from 'prop-types'; import styled from 'styled-components'; import CommentsAdjustments from './CommentsAdjustments'; import { normalizeCurrencyField, getCurrencyFomattedFloat } from '../../helpers'; import InputGroup from '../InputGroup'; import { Wrapper, Value, ValueComments,

ReactJS - get latitude on click and show it in input

会有一股神秘感。 提交于 2019-12-08 11:39:45
问题 Beginner here. I have a button that gets latitude and longitude using the geolocation API. I get the location fine on my console, but I'm having trouble showing them in a input box (so that I can then post the location information later). Below is my code for the component: export class GetLocation extends Component{ constructor(){ super(); this.state = { latitude: '', longitude: '' }; this.getMyLocation = this.getMyLocation.bind(this); } ComponentDidMount(){ this.getMyLocation(); }

How to get formvalues in handlechange?

匆匆过客 提交于 2019-12-08 08:59:30
问题 In my form I have an onChange event on one of the formfields: <div> <label>Last Name</label> <div> <Field name="lastName" component="input" type="text" placeholder="Last Name" onChange={() => this.handleChange()} /> </div> </div> When handleChange gets fired I want to get the formvalues : handleChange(){ //do calculation console.log('handlechange',this.props.values) } At the moment I am getting this.props.values = undefined? How can I get the formvalues? 回答1: You'll need to create a custom

In react JS fields losing focus after first onChange

淺唱寂寞╮ 提交于 2019-12-08 05:21:04
问题 I am using redux-form But When I am start typing focus goes out first time in react. In my component below, the input field loses focus after typing a character. While using Chrome's Inspector, it looks like the whole form is being re-rendered instead of just the value attribute of the input field when typing. Please see below code: <Field name='description' // onChange={this.handleChange.bind(this)} //value={this.state.description} component={props => { return ( <MentionTextArea {...props}

Redux Form, Radio Button Fields, how to support variable values?

南楼画角 提交于 2019-12-07 16:50:06
问题 In my react redux form, I have the following: <fieldset className="form-group"> <legend>Radio buttons</legend> {this.props.job_titles.map(jobTitle => ( <div className="form-check" key={jobTitle.id}> <label className="form-check-label"> <Field name="job_title_id" component="input" type="radio" value={jobTitle.id} /> {' '} {jobTitle.title} </label> </div> ))} </fieldset> This renders the radio buttons correctly, but when you click to select a radio button, the radio button never sets as

Handling submit in React/Redux form

纵然是瞬间 提交于 2019-12-07 16:36:19
问题 I want to capture the form values when a user submits a form. The React tutorial shows this: var CommentForm = React.createClass({ handleAuthorChange: function(e) { this.setState({author: e.target.value}); }, handleTextChange: function(e) { this.setState({text: e.target.value}); }, handleSubmit: function(e) { e.preventDefault(); var author = this.state.author.trim(); var text = this.state.text.trim(); if (!text || !author) { return; } render: function() { return ( <form className="commentForm

redux-form is refreshing the page onSubmit

我们两清 提交于 2019-12-07 06:32:10
问题 I have a redux form that when submitted, is causing the entire browser page to refresh which is not desired... What am I doing wrong here to cause the page to refresh on submit? Rate.js import React from 'react'; import RateForm from '../../components/rate/RateForm'; class Rate extends React.Component { handleSubmit(data) { alert('x') console.log('handleSubmit'); console.log(data); } render() { const fields = [ { name: 'execution', type: 'select', options: [ { label: '5', value: '5' }, ], },

Redux form: REGISTER_FIELD / UNREGISTER_FIELD get called after change or focus events

让人想犯罪 __ 提交于 2019-12-07 06:13:38
问题 I’m using Redux Form to render and handle form events in my React app. The following things are used: Initial values Field arrays Immutable.js Material UI Also, the field arrays are build using the initial values. export default connect( state => { return { buttonVisible, confirm, initialValues: Immutable.Map({ configuration_items: configuration_items, }) } } )(AssetConfiguration) The problem is that all the fields in the form get deregistered and registered on every change or focus event.

Action creators not showing in “this.props” with redux-form 6.0.0-rc.3

喜欢而已 提交于 2019-12-07 05:13:28
问题 When I used redux-form 5.3.1 I was able to access my action creators. But as I needed Material-UI, I updated it to 6.0.0-rc.3. Changes from 5.3.1 to 6.0.0: Removed fields from render(): const { handleSubmit, fields: { email, password, passwordConfirm }} = this.props; Removed errors validation from under inputs: {email.touched && email.error && <div className="error">{email.error}</div>} Removed fields array from export default: export default reduxForm({ form: 'signup', fields: ['email',