How to use Redux-Form with React-Bootstrap?

后端 未结 2 1517
无人及你
无人及你 2021-02-08 05:27

I am trying to use \"redux-form\": \"^6.7.0\" with \"react-bootstrap\": \"^0.31.0\"

My Component renders nicely, but when I press Submit, what I see is an empty object.<

2条回答
  •  旧时难觅i
    2021-02-08 05:51

    See: https://github.com/erikras/redux-form/issues/2917

    Oh, this was a great mystery. I followed the advice in https://github.com/react-bootstrap/react-bootstrap/issues/2210 and both the warning about additional props and the empty submit stopped.

    It seems you have to wrap the Bootstrap in your custom component (why?, I don't know). Also make sure you custom component is a stateless funcitonal component, or after the first key press, you field will blur and lose focus.

    There are some warnings in the documentation of redux-form about this.

    my custom field component FieldInput

      const FieldInput = ({ input, meta, type, placeholder, min, max }) => {
            return (
                
            )
        }
    

    and I invoke it like this:

    
    

    see also: https://github.com/erikras/redux-form/issues/1750

    So now, the definition of FieldInput and Config look like this:

    import React, { Component } from 'react'
    import { Field, reduxForm } from 'redux-form'
    import { connect } from 'react-redux'
    import { Form, FormControl, FormGroup, ControlLabel, Col, Button, Tooltip, OverlayTrigger } from 'react-bootstrap'
    import * as Act from '../dash/actions.js'
    import FaFolderOpen from 'react-icons/lib/fa/folder-open'
    import FaFileCodeO from 'react-icons/lib/fa/file-code-o'
    
    const FieldInput = ({ input, meta, type, placeholder, min, max }) => {
        return (
            
        )
    }
    
    const Config = ({ ServerPort, UserID, PortNumber, WWWUrl, SourcePath, FMEPath, pickFile, pickFolder, handleSubmit }) => {
        return (
            
    Watson Port: TCP port for Watson to use)}>

提交回复
热议问题