Code Monkey home page Code Monkey logo

Comments (4)

MBilalShafi avatar MBilalShafi commented on June 25, 2024 2

@aress31 Thank you for using MUI X Data Grid and providing useful feedback. 😊
The request you made makes sense and is already made previously in #5647
Fortunately it's already in our backlog and should be prioritized as some bandwidth is available.
Please feel free to checkout the discussion or hop in with your feedback on the mentioned ticket.

I'll close this one just to keep all the conversation on the same place.
Thank you.

from mui-x.

romgrk avatar romgrk commented on June 25, 2024

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 mui-x.

aress31 avatar aress31 commented on June 25, 2024

From an ease of use and DX perspective I would still prefer the onDensityChange handler to remain consistent with all the other handlers.

from mui-x.

romgrk avatar romgrk commented on June 25, 2024

@mui/xgrid Any other opinions on adding a prop here?

from mui-x.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.