Skip to content

Instantly share code, notes, and snippets.

@tristanpendergrass
Created October 26, 2017 16:15
Show Gist options
  • Select an option

  • Save tristanpendergrass/e3f4e7ddb430a99b592ac450deb32dfe to your computer and use it in GitHub Desktop.

Select an option

Save tristanpendergrass/e3f4e7ddb430a99b592ac450deb32dfe to your computer and use it in GitHub Desktop.
import { compose } from 'lodash/fp';
import React from 'react';
import { reduxForm, destroy } from 'redux-form';
import { connect } from 'react-redux';
import { withStyles } from 'material-ui/styles';
import ExpTextField from 'common/components/form/ExpTextField';
const styles = {
root: {
padding: 10
}
};
const mapDispatchToProps = (dispatch, { name }) => ({
destroyForm: () => dispatch(destroy(name)),
});
class RenameForm extends React.Component {
render() {
const {
classes,
handleSubmit,
error,
} = this.props;
const required = value => value ? undefined : 'Required';
return (
<div className={classes.root}>
<form onSubmit={handleSubmit}>
<div>{error}</div>
<ExpTextField name="name" label="Name" fullWidth autoFocus required validate={[required]} />
<button type="submit" style={{display: 'none'}} />
</form>
</div>
);
}
}
export default compose([
reduxForm(),
connect(null, mapDispatchToProps),
withStyles(styles),
])(RenameForm);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment