Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(Container|Divider|Loader|Rail): use React.forwardRef() #4248

Merged
merged 1 commit into from
Jul 26, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions src/elements/Container/Container.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
/**
* A container limits content to a maximum width.
*/
function Container(props) {
const Container = React.forwardRef(function (props, ref) {
const { children, className, content, fluid, text, textAlign } = props
const classes = cx(
'ui',
Expand All @@ -29,12 +29,13 @@ function Container(props) {
const ElementType = getElementType(Container, props)

return (
<ElementType {...rest} className={classes}>
<ElementType {...rest} className={classes} ref={ref}>
{childrenUtils.isNil(children) ? content : children}
</ElementType>
)
}
})

Container.displayName = 'Container'
Container.propTypes = {
/** An element type to render as (string or function). */
as: PropTypes.elementType,
Expand Down
7 changes: 4 additions & 3 deletions src/elements/Divider/Divider.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
/**
* A divider visually segments content into groups.
*/
function Divider(props) {
const Divider = React.forwardRef(function (props, ref) {
const {
children,
className,
Expand Down Expand Up @@ -43,12 +43,13 @@ function Divider(props) {
const ElementType = getElementType(Divider, props)

return (
<ElementType {...rest} className={classes}>
<ElementType {...rest} className={classes} ref={ref}>
{childrenUtils.isNil(children) ? content : children}
</ElementType>
)
}
})

Divider.displayName = 'Divider'
Divider.propTypes = {
/** An element type to render as (string or function). */
as: PropTypes.elementType,
Expand Down
7 changes: 4 additions & 3 deletions src/elements/Loader/Loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
* A loader alerts a user to wait for an activity to complete.
* @see Dimmer
*/
function Loader(props) {
const Loader = React.forwardRef(function (props, ref) {
const {
active,
children,
Expand Down Expand Up @@ -45,12 +45,13 @@ function Loader(props) {
const ElementType = getElementType(Loader, props)

return (
<ElementType {...rest} className={classes}>
<ElementType {...rest} className={classes} ref={ref}>
{childrenUtils.isNil(children) ? content : children}
</ElementType>
)
}
})

Loader.displayName = 'Loader'
Loader.propTypes = {
/** An element type to render as (string or function). */
as: PropTypes.elementType,
Expand Down
7 changes: 4 additions & 3 deletions src/elements/Rail/Rail.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
/**
* A rail is used to show accompanying content outside the boundaries of the main view of a site.
*/
function Rail(props) {
const Rail = React.forwardRef(function (props, ref) {
const {
attached,
children,
Expand Down Expand Up @@ -44,12 +44,13 @@ function Rail(props) {
const ElementType = getElementType(Rail, props)

return (
<ElementType {...rest} className={classes}>
<ElementType {...rest} className={classes} ref={ref}>
{childrenUtils.isNil(children) ? content : children}
</ElementType>
)
}
})

Rail.displayName = 'Rail'
Rail.propTypes = {
/** An element type to render as (string or function). */
as: PropTypes.elementType,
Expand Down
1 change: 1 addition & 0 deletions test/specs/elements/Container/Container-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import * as common from 'test/specs/commonTests'

describe('Container', () => {
common.isConformant(Container)
common.forwardsRef(Container)
common.rendersChildren(Container)
common.hasUIClassName(Container)

Expand Down
1 change: 1 addition & 0 deletions test/specs/elements/Divider/Divider-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import * as common from 'test/specs/commonTests'

describe('Divider', () => {
common.isConformant(Divider)
common.forwardsRef(Divider)
common.rendersChildren(Divider)
common.hasUIClassName(Divider)

Expand Down
1 change: 1 addition & 0 deletions test/specs/elements/Loader/Loader-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import * as common from 'test/specs/commonTests'

describe('Loader', () => {
common.isConformant(Loader)
common.forwardsRef(Loader)
common.hasUIClassName(Loader)
common.rendersChildren(Loader)

Expand Down
1 change: 1 addition & 0 deletions test/specs/elements/Rail/Rail-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const requiredProps = { position: 'left' }

describe('Rail', () => {
common.isConformant(Rail, { requiredProps })
common.forwardsRef(Rail, { requiredProps })
common.hasUIClassName(Rail, { requiredProps })
common.rendersChildren(Rail, { requiredProps })

Expand Down