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.

Custom wrapper component using "asField" causes warning for Checkbox and Select

See original GitHub issue

V 3.24.0

We use a wrapper component so we can easily update all forms on our site. While upgrading, I noticed the use of Checkbox and Select components causes a warning, “Check to make sure you have not registered two fields with the fieldName.” Here is a simplified version of what we have:

import {Form, asField, BasicText, Select, Checkbox} from 'informed';

export const MyInputWrapper = asField(props => {
  return <React.Fragment>
    {{
      'text': <BasicText {...props}/>,
      'select': <Select {...props}/>,
      'checkbox': <Checkbox {...props}/>
    }[props.type]}
  </React.Fragment>
});

function App() {
  return (
      <Form>
        {({}) => (
            <React.Fragment>
              <MyInputWrapper type="text" field="myText"/>
              <MyInputWrapper type="select" field="mySelect"/>
              <MyInputWrapper type="text" field="myText"/>
            </React.Fragment>
        )}
      </Form>
  );
}

export default App;

Is there something obvious I am doing wrong here? The form appears to work fine, but the warnings are filling up console.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:27 (22 by maintainers)

github_iconTop GitHub Comments

1reaction
joepuzzocommented, Nov 20, 2020

Happens to the best of us haha

0reactions
Luphridcommented, Nov 20, 2020

I definitely need to spend some time refactoring. I have a lot of “just make it work” code hanging about in here.

Read more comments on GitHub >

github_iconTop Results From Across the Web

React a component is changing an uncontrolled input of type ...
If your state is initialized with props.value being null React will consider your Checkbox component to be uncontrolled.
Read more >
Building a custom checkbox in React - LogRocket Blog
In this guide, we will cover how to build a custom checkbox in React without sacrificing accessibility for assistive technology.
Read more >
Building a Checkbox Component with React and styled ...
We now have a simple React component that wraps the native checkbox element. This component will be the foundation of our styled checkbox....
Read more >
Checkbox | Primer React
This Checkbox component is intended only as an ingredient for other custom components, or as a drop-in replacement for native HTML checkboxes ......
Read more >
Changelog - ACF
Fix - Uploading multiple files nested in a subfield no longer causes a ... Fix - Fixed bug in Checkbox field missing "selected"...
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