GithubHelp home page GithubHelp logo

Comments (5)

eleventhaus avatar eleventhaus commented on September 26, 2024 8

Figured it out for anyone else who might need it

Use CustomInput in the component attribute in the Field component.

import { Field, reduxForm } from "redux-form";

<Field
     name="additional_info"
     component={CustomInput} <----- here
     labelText="Additional Info"
     id="additional_info"
     formControlProps={{
          fullWidth: true
     }}
     inputProps={{
          multiline: true,
          rows: 5
     }}
/>

In CustomInput add input and value to props and then add value={value} and onChange={input.onChange} to component

import Input from "@material-ui/core/Input";

const {
      classes,
      formControlProps,
      labelText,
      id,
      labelProps,
      inputProps,
      error,
      white,
      inputRootCustomClasses,
      success,
      input, <-------------------- here
      value  <-------------------- here
    } = props;

<Input
     classes={{
          input: inputClasses,
          root: marginTop,
          disabled: classes.disabled,
         underline: underlineClasses
     }}
     id={id}
     {...inputProps}
     
        />


return (
    <FormControl {...formControlProps} className={formControlClasses}>
      {labelText !== undefined ? (
        <InputLabel
          className={classes.labelRoot + " " + labelClasses}
          htmlFor={id}
          {...labelProps}
        >
          {labelText}
        </InputLabel>
      ) : null}
      <Input
        classes={{
          input: inputClasses,
          root: marginTop,
          disabled: classes.disabled,
          underline: underlineClasses
        }}
        id={id}
        {...inputProps}
        value={value}  <-------------------- here
        onChange={input.onChange} <-------------------- here
      />
      {error ? (
        <Clear className={classes.feedback + " " + classes.labelRootError} />
      ) : success ? (
        <Check className={classes.feedback + " " + classes.labelRootSuccess} />
      ) : null}
    </FormControl>
  );

from ct-material-kit-pro-react.

einazare avatar einazare commented on September 26, 2024

Hello there @eleventhaus

I really do not understand your issue.
Why use Field from react-redux instead of our CustomInput?
It doesn't really make sense to me.

Best,
Manu

from ct-material-kit-pro-react.

eleventhaus avatar eleventhaus commented on September 26, 2024

My app uses Redux for state management. Is there another way to use Redux with CustomInput?

I'd like to use CustomInput for the template styling AND Redux for state management, together. Is that possible?

from ct-material-kit-pro-react.

einazare avatar einazare commented on September 26, 2024

Hello again, @eleventhaus ,

From what I know, Redux is used for state management.
I do not really see why you would need to work with their input, instead of ours.
You just send the state from Redux to our input as it's value, and you can assign an onChange handler for our CostumInput and that handler should call an action or action creator to your Redux.
But that is just how I would go about it.

Here is my tutorial on Redux: https://medium.freecodecamp.org/how-to-use-redux-in-reactjs-with-real-life-examples-687ab4441b85
And the Youtube one: https://www.youtube.com/watch?v=raKV5Rb8oOM&list=PLWxSJr7LCl87rGlQtTo2PoX8hboUU0R8a

Also, you can find more on the internet.

Hope this information will help you.

Best,
Manu

from ct-material-kit-pro-react.

eleventhaus avatar eleventhaus commented on September 26, 2024

I do not really see why you would need to work with their input, instead of ours.

I'd like to use both. I would like to use <CustomInput> for styling purposes

You just send the state from Redux to our input as it's value, and you can assign an onChange handler for our CustomInput

Redux-form does this all easily if you wire up their component to an already exists component like <CustomInput>. The problem is I'm having trouble connecting the two

from ct-material-kit-pro-react.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.