I am trying to create ref in functional component .But getting different output as compare to to class based component.
here is simple class based component .In class based component I am getting correct refs
here is class based component https://stackblitz.com/edit/react-vh86ou?file=src%2Ftabs.js
see ref mapping (correct ref mapping)

Same mapping I am trying to do with functional component but getting different output why ?
here is my function component https://stackblitz.com/edit/react-nagea2?file=src%2FApp.js
export default function App() {
useEffect(() => {
console.log('---', tabRefs);
}, []);
const getTabProps = ({ title, key, selected, tabIndex }) => ({
selected,
children: title,
key: tabPrefix + key,
id: tabPrefix + key,
ref: e => (tabRefs[tabPrefix + key] = e),
originalKey: key
});
Why I am getting Ref from HTMLLIELEMENT instead of TAB component ?
Update :
I am trying to get offsetWidth still not able to get
https://stackblitz.com/edit/react-nagea2?file=src%2FApp.js
useEffect(() => {
console.log('---', tabRefs);
Object.keys(tabRefs).forEach(key => {
console.log(key);
if (tabRefs[key]) {
const width = tabRefs[key].tab.offsetWidth;
console.log(width);
}
});
}, []);
