question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to use with material-ui TextField and React-Final-Form?

See original GitHub issue

I want use material-ui TextField like skin for Cleave and RFF for form. Can you help me?

import React from "react";
import Cleave from "cleave.js/react";
import TextField from "material-ui/TextField";

export default ({
  input: { name, onChange, value, ...restInput },
  meta,
  ...rest
}) => (
  <TextField
    {...rest}
    name={name}
    helperText={meta.touched ? meta.error : undefined}
    error={meta.error && meta.touched}
    inputProps={restInput}
  >
    <Cleave name={name} onChange={onChange} value={value}/>
  </TextField>
);

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

3reactions
popuguytheparrotcommented, Jul 11, 2018

@bogdansoare @ofarukcaki

import React from "react";
import Cleave from "cleave.js/react";
import { TextField } from "@material-ui/core";

function MaskedTextField(props) {
  const { options, inputRef, ...other } = props;
  return <Cleave {...other} ref={inputRef} options={options} />;
}

export default ({
  input: { name, onChange, value, ...restInput },
  meta,
  options,
  ...rest
}) => 
    <TextField
      {...rest}
      name={name}
      onChange={onChange}
      value={value}
      error={meta.error && meta.touched}
      helperText={meta && meta.touched ? meta.error : undefined}
      inputProps={{ ...restInput, options, value }}
      InputProps={{
        inputComponent: MaskedTextField
      }}
    />
  );
};

Need create adapter with cleave.js. CleaveTextField it is adapter like in example in RFF.

2reactions
wellyalcommented, Mar 20, 2019

Is there a way to keep the Material-UI design. I mean I did exactly like in your example but the input rendered wasn’t anything like the material-UI input.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Does [React Final Form] work with Material-UI 3.x?
You can't directly use @material-ui/core/TextField, you need to wrap it first: import React from 'react' import TextField from ...
Read more >
React Final Form - Material-UI Example - CodeSandbox
Demonstrates how to use Material-UI form controls. material-ui. 18.
Read more >
Examples - Final Form Docs
Demonstrates how to use React Final Form's parse and format props to control exactly how the data flows from the form state through...
Read more >
react-final-form Material-UI TextField - gists · GitHub
import React from 'react';. import {FieldRenderProps} from 'react-final-form';. import TextField, {TextFieldProps} from '@material-ui/core/TextField';.
Read more >
React Text Field component - Material UI - MUI
The TextField wrapper component is a complete form control including a label, input, and help text. It comes with three variants: outlined (default), ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found