Skip to content

Commit fca0a39

Browse files
froltimneutkens
authored andcommitted
examples/with-react-md: Fixed "Cannot read property 'focus' of undefined" (#961)
1 parent 3e34430 commit fca0a39

File tree

1 file changed

+19
-11
lines changed

1 file changed

+19
-11
lines changed

examples/with-react-md/pages/index.js

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import Head from 'next/head'
22
import Link from 'next/link'
33

4+
import { PureComponent } from 'react'
5+
46
import Avatar from 'react-md/lib/Avatars'
57
import Button from 'react-md/lib/Buttons/Button'
68
import FontIcon from 'react-md/lib/FontIcons'
@@ -28,17 +30,23 @@ const drawerHeaderChildren = [
2830
/>
2931
]
3032

31-
const NavigationLink = (props) => {
32-
const { href, as, children, ..._props } = props
33-
return (
34-
<div {..._props}>
35-
<Link href={href} as={as}>
36-
<a className='md-list-tile' style={{padding: 0, overflow: 'hidden'}}>
37-
{children}
38-
</a>
39-
</Link>
40-
</div>
41-
)
33+
class NavigationLink extends PureComponent {
34+
// NOTE: Don't try using Stateless (function) component here. `ref` is
35+
// required by React-MD/AccessibleFakeButton, but Stateless components
36+
// don't have one by design:
37+
// https://github.com/facebook/react/issues/4936
38+
render () {
39+
const { href, as, children, ..._props } = this.props
40+
return (
41+
<div {..._props} style={{padding: 0}}>
42+
<Link href={href} as={as}>
43+
<a className='md-list-tile md-list-tile--mini' style={{width: '100%', overflow: 'hidden'}}>
44+
{children}
45+
</a>
46+
</Link>
47+
</div>
48+
)
49+
}
4250
}
4351

4452
export default () => {

0 commit comments

Comments
 (0)