Giter Site home page Giter Site logo

Comments (9)

codepunkt avatar codepunkt commented on May 21, 2024 3

@romanlex it seems we ran into similar problems.

For me, calling .submit() on the form did not work & reloaded the whole app.
See this tweet for more information on how i solved it.

Maybe you can even chime in and tell me why the heck the things i did actually worked, when .submit() doesn't.

from react-final-form.

erikras avatar erikras commented on May 21, 2024 2

Made a FAQ about this.

from react-final-form.

romanlex avatar romanlex commented on May 21, 2024

Now I use Portal https://gist.github.com/romanlex/bf61fb0c3db2ef1a6c68cb07a0904da2 but I think need remote submit method (

from react-final-form.

erikras avatar erikras commented on May 21, 2024

Wow, look at you using <Fragment> already! 😮

Can you not pass handleSubmit to your portal component?

from react-final-form.

romanlex avatar romanlex commented on May 21, 2024

if I remove handleSubmit my button doesnt work because buttons render to another domNode with Ract.createPortal

        <CallbackForm
          buttonPortalId={containerActionId}
          subscription={{ submitting: true, pristine: true }}
        />
        <footer
          className="divider-block__footer-actions"
          id={containerActionId}>
              // my buttons
       </footer>

from react-final-form.

erikras avatar erikras commented on May 21, 2024

It's not very React-y, but I wonder if you could use the DOM itself to achieve this, by calling submit()?

<form id="myForm" onSubmit={handleSubmit}> ... </form>
...
<button type="button" onClick={() => document.getElementById('myForm').submit()}>
  Submit
</button>

from react-final-form.

elrumordelaluz avatar elrumordelaluz commented on May 21, 2024

Beyond this little issue, the switch from redux-form into react-final-form seems really simple.
Thanks @erikras for the great work!

Thanks @romanlex for the workaround, I am also pretty curious on why only this way works as expected.

from react-final-form.

romanlex avatar romanlex commented on May 21, 2024

Hello! Why I use Portal but not use document.getElementById() or submit by Closure?
Because I want use native state by react-final-form without any HOC with custom form state
I want disable button or use another function.

      <button
              className="btn btn-outline-secondary btn-block"
              type="button"
              onClick={reset}
              disabled={submitting || pristine}>
              Reset form
      </button>
      <button
              className="btn btn-primary btn-block"
              type="submit"
              onClick={handleSubmit}
              disabled={submitting}>
              Submit
       </button>

from react-final-form.

lock avatar lock commented on May 21, 2024

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

from react-final-form.

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.