Skip to content
This repository has been archived by the owner on Apr 6, 2023. It is now read-only.

Clear inputs after submit #16

Closed
condini-mastheus opened this issue May 14, 2019 · 1 comment
Closed

Clear inputs after submit #16

condini-mastheus opened this issue May 14, 2019 · 1 comment

Comments

@condini-mastheus
Copy link

condini-mastheus commented May 14, 2019

I have the following code:

import React, { useState } from 'react';

import Calendar from 'react-calendar';
import { Form, Input } from '@rocketseat/unform';
import * as Yup from 'yup';
import { connect } from 'react-redux';
import { bindActionCreators } from 'redux';

import { Creators as PostsActions } from '~/store/ducks/posts';

function Main({ savePostRequest, getPostsRequest, posts }) {
  const today = new Date();

  function handleSubmit(data) {
    const { post } = data;
    savePostRequest({ post, date });
  }

  return (
    <Container>
         <Form schema={schema} onSubmit={handleSubmit}>
                <Input
                    type="text"
                    name="post"
                    placeholder={
                    'Type something you are grateful for and press "Enter" to share with everyone'
                    }
                    autoComplete="off"
                    disabled={posts.isSending}
                    autoFocus
                />
            </Form>   
    </Container>
  );
}

const mapStateToProps = state => ({
  posts: state.posts,
});

const mapDispatchToProps = dispatch => bindActionCreators(PostsActions, dispatch);

export default connect(
  mapStateToProps,
  mapDispatchToProps,
)(Main);

How to I clear the input field after form submit?

@diego3g
Copy link
Contributor

diego3g commented May 14, 2019

For now, there is no way of doing that, i would really appreciate if we could discuss it inside #17.

I will close the issue since we are discussing it in another thread, feel free to reopen if you think we are missing something here.

@diego3g diego3g closed this as completed May 14, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants