Unable to preserve the value of react material-ui autoCompletion using formik

Greetings everyone! Today, I wanted to address an issue that has been causing some trouble for me recently. I've been utilizing the autoCompletion feature from materiall-ui along with formik in reactjs. However, I've been facing difficulties when it comes to filling out the autoCompletion field in edit mode. It seems that I am unable to display the precise value in my form, resulting in the loss of data when transitioning between different steps.

Answer №1

To properly set the value in Autocomplete, it is recommended to utilize initialValue. There are known data binding issues with formik + material ui, but you can explore a sample example on this page. For a practical demonstration, check out this Codesandbox example. PS: If there are any dependencies error, remember to reload the sandbox.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Having trouble applying class names in ReactJS using a switch statement

I need help troubleshooting an issue where badges are not rendering in different colors based on the payment status of an order. I keep receiving an error message stating; buttonColour is not defined {(() => { let buttonColour switch (paymen ...

The maximum date setting in the Material UI MobileDatePicker is not functioning correctly

I am having trouble understanding how to use the maxDate prop in the MobileDatePicker component. Whenever I attempt to set it as maxDate={new Date()}, I find that I can still select dates beyond the current date. Visit this codesandbox for more details &l ...

Activating a function on a click or item selection in React using Office UI Fabric's

<div> <CommandBar areNamesVisible={false} areIconsVisible={true} items={[ { name:"James Towns", className:"noHoverEffect", }, { key:"Info", icon:"Contact", onItemClick={this.handlePanel} ...

React Error: The module 'common' could not be located

I've been searching high and low on the web for a solution to this problem, but so far, nothing I've found has done the trick. I'm fairly new to React, but a friend of mine requested my assistance with some CSS work on his React project, so ...

I keep encountering an error when trying to import an image from the asset folder in Next.js

After successfully creating a React app, I encountered an error when trying to incorporate all the files into a Shopify app where Next.js is present. import React, {createContext, useState} from "react"; import bag from &quo ...

Having trouble with `Routes.push()` in NextJS?

When attempting to access the app dashboard without authentication, I wanted to redirect the user to the homepage. However, I encountered an issue with Route.push() not working as expected. To test this behavior further, I modified Router.push('/&apo ...

What is the process for updating a value on a client site with mongodb?

I am currently using a combination of React for the front-end and Node.js with MongoDB for the back-end. In my project, I have developed a custom hook to fetch data. Below is the code snippet for this custom hook: import { useEffect, useState } from " ...

Issue retrieving nested object in NextJS

view-component.js const ViewComponent = () => { const route = useRoute(); //All good here const data = fetchData(); console.log(data); //Issue arises with this line const profileData = data.profile; console.log(profileData) ...

Having trouble with React Router 4 in a subfolder?

import { BrowserRouter as Router, Route } from 'react-router-dom' <Router> <switch> <Route exact path='/' component={main} /> <Route path='/build/signup' component={SignUp} /> </swit ...

Mastering the art of customizing classes and styles in material-ui (React)

I am facing a challenge with version 1.2.1 of material-ui. My goal is to make the AppBar component transparent by overriding its styles as per the documentation here. This is the code snippet I have been working on: import React, { Component } from ' ...

Is it possible to invoke React's useState and useCallback multiple times within a singular functional component? And if it is, how exactly does the process function?

After scouring the official React documentation and various blog posts, it seems there is no mention of this particular query. In my opinion, it could be beneficial to structure multiple state variables in a component like so: function MyComponent() { ...

Data fetched using React Query

When using React Query to fetch data, the function runs smoothly. After console.logging the 'data' variable from React Query, it prints an array of objects as expected and handles states efficiently between loading, success, error. The issue ar ...

Utilize an API within a content management system in a Next.js environment

I am having trouble accessing an endpoint in next.js from a headless CMS proxy in Node.js, and I can't seem to make it work properly. Instead of redirecting me to the desired site, I am encountering the following error: If you need assistance, refer ...

Can someone guide me on identifying the type of object in React/Typescript?

Can anyone help me remove this unnecessary definition? const [nextLocation, setNextLocation] = useState(null) as any[]; I have been struggling with this in my React Router 6 project. I've looked through the documentation but haven't found a suit ...

Unable to adjust the height of an MP4 video to properly display within a Material Box in both landscape and portrait orientations

While I have been learning JavaScript React, I encountered an issue with positioning an MP4 movie. You can view the code in this Codesandbox If you check out the FileContentRenderer.jsx file, you will see that the html5-video is used for the MP4. The g ...

Executing the callback function

I am facing a situation where I have a Modelmenu nested within the parent component. It is responsible for opening a modal window upon click. Additionally, there is a child component in the same parent component that also needs to trigger the opening of a ...

The entire space should be filled with the background

My goal is to achieve the following while addressing some current issues: The background is currently limited to affecting only the container. I want it to span the entire area. There needs to be space between the cards and padding inside them. https://i ...

Modify the color of the custom horizontal stepper's font

result Adding a personalized horizontal stepper is what I aim to do, but the font color seems too similar to the background color; how can I change it? Visit this link for more information on customizing horizontal steppers. ...

Having difficulty transmitting a response string from my Express server to my React front-end

I'm encountering an issue with responding to a Fetch request using a URL in string format. Despite the examples I've come across appearing straightforward, I suspect that my cors middleware might be causing some complications. Below is the setup ...

Encountering errors in Vite SSR build when using MUI icons and date-time-picker

I am working on a VITE ssr playground with additional MUI packages available on GitHub. When I import any MUI icon and adapter from the date-time-picker, everything works fine in development mode. However, when I build the project, the server stops with e ...