Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

React warning for update forms #824

Open
4 tasks done
hein-j opened this issue Feb 14, 2023 · 2 comments
Open
4 tasks done

React warning for update forms #824

hein-j opened this issue Feb 14, 2023 · 2 comments
Labels
bug An issue which has been identified as a bug cms An issue identified as a cms bug/feature studio-ui An issue that needs to be tracked by Studio Console team

Comments

@hein-j
Copy link

hein-j commented Feb 14, 2023

Before opening, please confirm:

App Id

n/a

Region

n/a

Environment name

n/a

Figma File Version (if applicable)

No response

Amplify CLI Version

No response

If applicable, what version of Node.js are you using?

No response

What operating system are you using?

No response

Browser type?

No response

Describe the bug

If I have the following schema:

type Cat @model {
name: String
age: Int
}

and save a Cat with no name (I can because it's an optional field)
and then try to update the Cat with an auto-generated UpdateCatForm,
I get the following warning in the console:

A component is changing a controlled input to be uncontrolled. This is likely caused by the value changing from a defined to undefined, which should not happen. Decide between using a controlled or uncontrolled input element for the lifetime of the component.

Expected behavior

The form should handle nullish values coming from Dynamo gracefully.

Reproduction steps

See description.

Project Identifier

No response

Additional information

No response

@hein-j hein-j added the pending-triage An issue that is pending triage label Feb 14, 2023
@ykethan
Copy link
Member

ykethan commented Feb 14, 2023

Hey @hein-j, I was not able to reproduce the issue. To understand in the UI builder using the updateCat form, did you add a new field then hit update model to update the model in the data modelling page? When i did that I observed the following in the browser console.
image

additionally, also observed the following when switching from a data modelling page to content.
image
refreshing the page fixed it. we should probably be more explicit for a need to refresh.

@ykethan ykethan added studio-ui An issue that needs to be tracked by Studio Console team pending-response An issue is pending response from the issue requestor labels Feb 14, 2023
@hein-j
Copy link
Author

hein-j commented Feb 23, 2023

@ykethan - I can repro.
Here are the steps:

  1. Save a Cat with no name.
  2. In your local project, load the cat in the update form. (see code below).
  3. Observe React error in console.

The warning by itself is not a problem, but we rely on this component being properly controlled. Since it is not, you can see functionalities break, such as the Reset button not working.

Amplify.configure(awsconfig);

function App() {
  const [cat, setCat] = useState()
 async function load() {
  const cats = await DataStore.query(Cat);
  setCat(cats[0])
  }
  return (
    <AmplifyProvider>
      <button onClick={load}>Click</button>
     <CatUpdateForm cat={cat}/>
    </AmplifyProvider>
  );
}

export default App;

@github-actions github-actions bot removed the pending-response An issue is pending response from the issue requestor label Feb 23, 2023
@ykethan ykethan added bug An issue which has been identified as a bug and removed pending-triage An issue that is pending triage labels Mar 16, 2023
@ykethan ykethan added the cms An issue identified as a cms bug/feature label Aug 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug An issue which has been identified as a bug cms An issue identified as a cms bug/feature studio-ui An issue that needs to be tracked by Studio Console team
Projects
None yet
Development

No branches or pull requests

2 participants