Git Product home page Git Product logo

Comments (3)

crutchcorn avatar crutchcorn commented on May 31, 2024 1

This is where our docs could be improved. Unfortunately, due to the complexity of FormData parsing, we're handing off that "everything is a string" parsing to decode-formdata: https://github.com/fabian-hiller/decode-formdata

Where you need to pass in the schema you expect the FormData to parse to on the server. Closing as a can't fix, but do feel free to make a PR to docs to clarify this for us if you're comfortable doing so :)

from form.

crutchcorn avatar crutchcorn commented on May 31, 2024 1

@probablykabari thanks for reporting these. Glad to see someones validating our SSR stuff in prod.

Both of these sound like bugs, not docs issues. The first should be easy to solve and the second might be a slight addon to mergeForm or something.

PRs are always welcome 😊

from form.

probablykabari avatar probablykabari commented on May 31, 2024

@crutchcorn Mind if I make a bigger PR to address the following, all related to using server validation. Thus far my usage in practice has been less than welcoming.

  • validateFormData doesn't ever return a complete FormState, only errors. This creates a bit of an annoyance because you use this function to handle errors, but if you want to use the data for anything (especially in TS) you have to decode FormData again. Ideally this method would return values after your validator has already done this for you. Also the docs should reflect this.
  • useTransform seems to break if the response value of an action is null. Not a big deal but unexpected and this hook and it's use are a mystery. This is sometimes an issue (in NextJS) when redirecting from a server action. I'm guessing the transform docs are in the vanilla js library?
  • mergeForm with useFormState with a default state deeply merges with the default. So, if there is an array value in the default it incorrectly will merge server values with default values rather than replacing them on initial load.

from 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.