首页 > 解决方案 > React-Tab id tag not working how do I getElementByID?

问题描述

I have a react app, there is a tab list:

  render() {
    return (
      <div className="App">
       <Tabs>
          <TabList>
            <Tab id="abc">ABC</Tab>
            <Tab>DEF</Tab>
          </TabList>
        </Tabs>
      </div>
    );
  }

In the console getElementById("abc") returns null. Why?

Proper way to get an element in React JS code?

标签: reactjs

解决方案


我认为您的意思是document.getElementById("abc")(注意小写d)


推荐阅读