You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've been having trouble getting my slider to work when I use its value={...} property. For context, there is a slider for each row in a MUI Data Grid
I will layout the code accordingly so it makes sense:
TABLE.tsx
const handleSlide = (id, newValue) => {
const dataRows = [...backendData];
const currentValue = dataRows.find((row) => row.id === id)!.comfortability;
setBackendData(dataRows);
//This will be replaced with a fetch POST request once I know its functionally sound
}
As commented, this is where the pass back ends, here I will get the row ID and the slider's new value in order to make a query and modify a MySQL table (this latter part is irrelevant, only added in for context)
This is where the function call to handleSlide is made. For context, this is one of the columns instantiated for the MUI DataGrid. (comfortability is simply a number value)
I created a custom prop called onChange which calls handleSlide. I also pass in params.row.id as id and params.row.numberValue as passedInValue into the <RowSlider> component.
When I use the value property of the MUI Slider, it prevents me from moving the slider in the UI. However, I need this value property because:
The value needs to be initially set via data from MySQL to reflect the database accurately
When the slider is moved in the UI, it should (in theory)
Change the value state, which in turn, updates the value of the slider
And make a callback to onChange will the updated value and row id.
Please help me get my slider moving! I hope I did not include too much information, I know sometimes things can be finicky and I wanted to include all the relevant contextual information in case it helps.
Thank you~
The text was updated successfully, but these errors were encountered:
I've been having trouble getting my slider to work when I use its
value={...}
property. For context, there is a slider for each row in a MUI Data GridI will layout the code accordingly so it makes sense:
TABLE.tsx
As commented, this is where the pass back ends, here I will get the row ID and the slider's new value in order to make a query and modify a MySQL table (this latter part is irrelevant, only added in for context)
This is where the function call to
handleSlide
is made. For context, this is one of the columns instantiated for the MUI DataGrid. (comfortability
is simply a number value)I created a custom prop called
onChange
which callshandleSlide
. I also pass inparams.row.id
asid
andparams.row.numberValue
aspassedInValue
into the<RowSlider>
component.RowSlider.tsx
Here is where the issue occurs...
When I use the
value
property of theMUI Slider
, it prevents me from moving the slider in the UI. However, I need this value property because:value
state, which in turn, updates the value of the slideronChange
will the updated value and row id.Please help me get my slider moving! I hope I did not include too much information, I know sometimes things can be finicky and I wanted to include all the relevant contextual information in case it helps.
Thank you~
The text was updated successfully, but these errors were encountered: