1- import React , { HTMLAttributes , forwardRef } from 'react'
1+ import React , { HTMLAttributes , forwardRef , useRef } from 'react'
22import PropTypes from 'prop-types'
33import classNames from 'classnames'
44import { Transition } from 'react-transition-group'
55
6+ import { useForkedRef } from '../../utils/hooks'
67export interface CTabPaneProps extends HTMLAttributes < HTMLDivElement > {
78 /**
89 * A string of all className you want applied to the base component.
@@ -24,6 +25,9 @@ export interface CTabPaneProps extends HTMLAttributes<HTMLDivElement> {
2425
2526export const CTabPane = forwardRef < HTMLDivElement , CTabPaneProps > (
2627 ( { children, className, onHide, onShow, visible, ...rest } , ref ) => {
28+ const tabPaneRef = useRef ( )
29+ const forkedRef = useForkedRef ( ref , tabPaneRef )
30+
2731 const getTransitionClass = ( state : string ) => {
2832 return state === 'entered' && 'show'
2933 }
@@ -37,11 +41,11 @@ export const CTabPane = forwardRef<HTMLDivElement, CTabPaneProps>(
3741 className ,
3842 )
3943 return (
40- < Transition in = { visible } onEnter = { onShow } onExit = { onHide } timeout = { 150 } >
44+ < Transition in = { visible } nodeRef = { tabPaneRef } onEnter = { onShow } onExit = { onHide } timeout = { 150 } >
4145 { ( state ) => {
4246 const transitionClass = getTransitionClass ( state )
4347 return (
44- < div className = { classNames ( _className , transitionClass ) } { ...rest } ref = { ref } >
48+ < div className = { classNames ( _className , transitionClass ) } { ...rest } ref = { forkedRef } >
4549 { children }
4650 </ div >
4751 )
0 commit comments