Skip to content

Commit 8b5c445

Browse files
committed
chore(Container|Divider|Loader|Rail): use React.forwardRef() (#4248)
1 parent 1886eb2 commit 8b5c445

File tree

8 files changed

+20
-12
lines changed

8 files changed

+20
-12
lines changed

src/elements/Container/Container.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import {
1515
/**
1616
* A container limits content to a maximum width.
1717
*/
18-
function Container(props) {
18+
const Container = React.forwardRef(function (props, ref) {
1919
const { children, className, content, fluid, text, textAlign } = props
2020
const classes = cx(
2121
'ui',
@@ -29,12 +29,13 @@ function Container(props) {
2929
const ElementType = getElementType(Container, props)
3030

3131
return (
32-
<ElementType {...rest} className={classes}>
32+
<ElementType {...rest} className={classes} ref={ref}>
3333
{childrenUtils.isNil(children) ? content : children}
3434
</ElementType>
3535
)
36-
}
36+
})
3737

38+
Container.displayName = 'Container'
3839
Container.propTypes = {
3940
/** An element type to render as (string or function). */
4041
as: PropTypes.elementType,

src/elements/Divider/Divider.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import {
1313
/**
1414
* A divider visually segments content into groups.
1515
*/
16-
function Divider(props) {
16+
const Divider = React.forwardRef(function (props, ref) {
1717
const {
1818
children,
1919
className,
@@ -43,12 +43,13 @@ function Divider(props) {
4343
const ElementType = getElementType(Divider, props)
4444

4545
return (
46-
<ElementType {...rest} className={classes}>
46+
<ElementType {...rest} className={classes} ref={ref}>
4747
{childrenUtils.isNil(children) ? content : children}
4848
</ElementType>
4949
)
50-
}
50+
})
5151

52+
Divider.displayName = 'Divider'
5253
Divider.propTypes = {
5354
/** An element type to render as (string or function). */
5455
as: PropTypes.elementType,

src/elements/Loader/Loader.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import {
1616
* A loader alerts a user to wait for an activity to complete.
1717
* @see Dimmer
1818
*/
19-
function Loader(props) {
19+
const Loader = React.forwardRef(function (props, ref) {
2020
const {
2121
active,
2222
children,
@@ -45,12 +45,13 @@ function Loader(props) {
4545
const ElementType = getElementType(Loader, props)
4646

4747
return (
48-
<ElementType {...rest} className={classes}>
48+
<ElementType {...rest} className={classes} ref={ref}>
4949
{childrenUtils.isNil(children) ? content : children}
5050
</ElementType>
5151
)
52-
}
52+
})
5353

54+
Loader.displayName = 'Loader'
5455
Loader.propTypes = {
5556
/** An element type to render as (string or function). */
5657
as: PropTypes.elementType,

src/elements/Rail/Rail.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import {
1616
/**
1717
* A rail is used to show accompanying content outside the boundaries of the main view of a site.
1818
*/
19-
function Rail(props) {
19+
const Rail = React.forwardRef(function (props, ref) {
2020
const {
2121
attached,
2222
children,
@@ -44,12 +44,13 @@ function Rail(props) {
4444
const ElementType = getElementType(Rail, props)
4545

4646
return (
47-
<ElementType {...rest} className={classes}>
47+
<ElementType {...rest} className={classes} ref={ref}>
4848
{childrenUtils.isNil(children) ? content : children}
4949
</ElementType>
5050
)
51-
}
51+
})
5252

53+
Rail.displayName = 'Rail'
5354
Rail.propTypes = {
5455
/** An element type to render as (string or function). */
5556
as: PropTypes.elementType,

test/specs/elements/Container/Container-test.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import * as common from 'test/specs/commonTests'
55

66
describe('Container', () => {
77
common.isConformant(Container)
8+
common.forwardsRef(Container)
89
common.rendersChildren(Container)
910
common.hasUIClassName(Container)
1011

test/specs/elements/Divider/Divider-test.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import * as common from 'test/specs/commonTests'
55

66
describe('Divider', () => {
77
common.isConformant(Divider)
8+
common.forwardsRef(Divider)
89
common.rendersChildren(Divider)
910
common.hasUIClassName(Divider)
1011

test/specs/elements/Loader/Loader-test.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import * as common from 'test/specs/commonTests'
77

88
describe('Loader', () => {
99
common.isConformant(Loader)
10+
common.forwardsRef(Loader)
1011
common.hasUIClassName(Loader)
1112
common.rendersChildren(Loader)
1213

test/specs/elements/Rail/Rail-test.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ const requiredProps = { position: 'left' }
99

1010
describe('Rail', () => {
1111
common.isConformant(Rail, { requiredProps })
12+
common.forwardsRef(Rail, { requiredProps })
1213
common.hasUIClassName(Rail, { requiredProps })
1314
common.rendersChildren(Rail, { requiredProps })
1415

0 commit comments

Comments
 (0)