question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[FormControl] Expose the form control state

See original GitHub issue

How does one get the Context managed by a <FormControl/> into one’s own component that is intended to be a child of the <FormControl/>. The form control does not seem to pass disabled, focused, error as properties and also does not use React’s new context API. Could you add this answers to the documentation somewhere.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:3
  • Comments:15 (9 by maintainers)

github_iconTop GitHub Comments

4reactions
oliviertassinaricommented, Jul 4, 2019

Interesting, we will remove withFormControlContext in the near future. I propose we replace it with a useFormControlState (#15231). I believe that we could expose this hook.

1reaction
mfolnoviccommented, May 22, 2019

I’m implementing a wrapper controlled component (with styling and some additional functionality) around TextField. I’m using Storybook for testing/documenting this.

I would like to be able to write a story that “forces” this component in other states (e.g. focus).

From code, I inferred this could be done by exposing FormControlContext, which is why I’m writing my use case in this issue. 😃

It would be easiest if I could write something like:

<FormControlContext.Provider value={{focused: true}}>
  <TextField ... />
</FormControlContext.Provider>
Read more comments on GitHub >

github_iconTop Results From Across the Web

FormGroup and FormControl in Angular - LogRocket Blog
Form groups wrap a collection of form controls. Just as the control gives you access to the state of an element, the group...
Read more >
mui/material-ui - [FormControl] Expose the form control state
In my case I agree that there is no need to update FormControlContext from parent without using props. Handlers (onBlur, ...) exposed on ......
Read more >
Angular Custom Form Controls - Complete Guide
In this guide, we are going to learn exactly how to take an existing custom form control component and make it fully compatible...
Read more >
Get access to FormControl from the custom form component in ...
I'm injecting the parent FormGroup to the component and then getting the specific FormControl from it using control name obtained through ...
Read more >
FormControl - Angular
Tracks the value and validation status of an individual form control. ... Construct a FormControl with no initial value or validators.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found