Hi: I have the following code in a file I am using inside of my Html Custom Element. It does not render when loaded. import React, { useState } from "react"; const Tabs = () => { const [activeTab, setActiveTab] = useState('tab1'); return ( <div className="Tabs"> {/* Tab nav */} <ul className="nav"> <li className={activeTab === "tab1" ? "active" : ""}>Tab 1</li> <li className={activeTab === "tab2" ? "active" : ""}>Tab 2</li> </ul> <div className="outlet"> {/* content will be shown here */} </div> </div> ); }; export default Tabs;
If I replace the "const [activeTab, setActiveTab] = useState('tab1'); " line with "const activeTab = 'tab1'", it renders. Now I have v1.0.47 version of @wix/react-velo loaded and the library's ReadMe gives exactly this example as what is supposed to work. Anyone have any idea why useState hook might not be working for me?
I'm a newbie, so any assistance would be greatly appreciated.
If you are using that library, it is not intended to be used in an HTML iFrame element.
For a more complete example on how to utilize the react-velo NPM package, I would check out this workshop that was hosted during our devcon last year
https://github.com/tomenden/devcon-declarative-workshop
In looking at the debugging tools in Chrome, I am seeing this error: Cannot read properties of null (reading 'useState') Any idea what that might be about and how to get around it?