-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
[DataGrid] Add density change event #10080
Comments
I would suggest that you keep listening to the state changes but only trigger your logic when specific parts of it change. This is flexible enough to cover all use cases, and is exactly what we do inside the grid to trigger targetted re-renders. // Select the parts of the state you care about
// NOTE: make sure to use the public selectors from the docs, the state's inner structure isn't public
const selector = state => [state.a, state.b, state.c]
const cachedValues = useRef([])
useEffect(() => {
return apiRef.current.subscribeEvent('stateChange', state => {
const values = selector(state)
if (!values.every((v, i) => v === cachedValues.current[i])) {
// [insert save state code here]
cachedValues.current = values
}
})
}, []) I don't like the idea of adding a prop for this specifically, it's too specific and doesn't have a significant advantage over using the implementation above. Does that solve your issue? |
From an ease of use and |
@mui/xgrid Any other opinions on adding a prop here? |
@aress31 Thank you for using MUI X Data Grid and providing useful feedback. 😊 I'll close this one just to keep all the conversation on the same place. |
Duplicates
Latest version
Summary 💡
It seems like there is still no
onDensityChange
handler, listening for the entire state change is an overkill and will get triggered at every change and therefore to stick with the current logic ofvariable
+handler
I would love to see anonDensityChange
.Examples 🌈
No response
Motivation 🔦
Improving DX and providing more control over preference persistence.
Order ID 💳 (optional)
No response
The text was updated successfully, but these errors were encountered: