Skip to content
This repository was archived by the owner on Jun 20, 2022. It is now read-only.

Commit ebbfc1a

Browse files
committed
docs(website): document refs
1 parent 8cabdc9 commit ebbfc1a

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

docs/advanced/Refs.mdx

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
---
2+
name: Refs
3+
menu: Advanced
4+
---
5+
6+
import { Playground } from 'docz'
7+
import { Input, styled } from '@smooth-ui/core-sc'
8+
9+
# Refs
10+
11+
Passing a `ref` prop to a Smooth UI component will give you the ref of the DOM node.
12+
13+
<Playground>
14+
{() => {
15+
class Form extends React.Component {
16+
constructor(props) {
17+
super(props);
18+
this.inputRef = React.createRef()
19+
}
20+
21+
render() {
22+
return (
23+
<Input
24+
ref={this.inputRef}
25+
placeholder="Hover to focus!"
26+
onMouseEnter={() => {
27+
this.inputRef.current.focus()
28+
}}
29+
/>
30+
)
31+
}
32+
}
33+
34+
return <Form />
35+
}}
36+
</Playground>

0 commit comments

Comments
 (0)