Giter Site home page Giter Site logo

Comments (6)

cliedeman avatar cliedeman commented on August 16, 2024 1

Ah I think I get it now. The question could be why do I explicitly exclude these fields

export interface CheckboxProps
  extends FieldProps,
    Omit<
      MuiCheckboxProps,
      'form' | 'checked' | 'defaultChecked' | 'name' | 'onChange' | 'value'
    > {}

The reason is that I want exactly one place for state to be stored. That being said modifying state outside of formik happen often enough.

Would this pattern work for you?
https://codesandbox.io/s/goofy-jepsen-2s4f4

Otherwise you can always create your own special case field.

Ciaran

from formik-mui.

cliedeman avatar cliedeman commented on August 16, 2024

Hi @tgrrr, Thanks for the example but I am struggling to see where it is breaking.

Is there a specific reason you have state outside of formik?

const [toggle, setToggle] = useState(false); looks very strange to me

from formik-mui.

tgrrr avatar tgrrr commented on August 16, 2024

I'm not sure why people wouldn't want control to get + set state outside of Formik itself.

We don't just interact with form components when we hit a submit button.

Some components interact with one another, and other components. Eg. Setting the value on a checkbox hides another component.

The example you copied is just managing state with hooks. It can be swapped out for setState, redux, or any other state management.

The point is that there's freedom to interact with react's state in Formik. Why wouldn't this also exist in Formik-Material?

from formik-mui.

tgrrr avatar tgrrr commented on August 16, 2024

Yes, I feel like that is exactly the question, thanks.

Would this pattern work for you?
Which pattern do you mean?

from formik-mui.

tgrrr avatar tgrrr commented on August 16, 2024

Why was this closed @cliedeman?

from formik-mui.

cliedeman avatar cliedeman commented on August 16, 2024

Because it’s working as intended. This library delegates all state management to formik.

from formik-mui.

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.