Material-ui: Paper doesn't accept a ref for it's div

Created on 10 Nov 2016  路  4Comments  路  Source: mui-org/material-ui

I'd like to access the div in the Paper implementation for animation purposes, but currently the ref method returns the Paper object, not the div (as per React's normal behaviour.)

render() {
  <Paper ref={ (ref) => this.ref = ref } onTouchTap={ console.log(this.ref) } />
}

I'm proposing an extra prop (something like 'divRef'?) that can be passed down to be added to the div. Thoughts? I imagine this would be valuable across a large number of components, so I assume people will have an opinion about the neatest way to do it.

Paper discussion

Most helpful comment

@simonhildebrandt Why not using the findDOMNode API for that use case?
However, you raised a good point. As we are using more and more stateless functional component on the next branch. That issue is going to rise.
We expose a rootRef property on the List component for an internal use case.
We could generalize this approach.

All 4 comments

@simonhildebrandt Why not using the findDOMNode API for that use case?
However, you raised a good point. As we are using more and more stateless functional component on the next branch. That issue is going to rise.
We expose a rootRef property on the List component for an internal use case.
We could generalize this approach.

Closing this due to inactivity.

@oliviertassinari React developers intend to deprecate the findDOMNode API eventually - https://github.com/yannickcr/eslint-plugin-react/issues/678

I'd appreciate a prop to get a ref for the div too.

@alexanthony I have been removing some ref properties lately #10025. As we encourage the usage of the findDOMNode API until React find a better one #9768.

Was this page helpful?
0 / 5 - 0 ratings