You cannot use Hooks in a class component. Hooks are to be used only in Functional Component
const CreateService = () => {
const [serviceToUse, setServiceToUse] = useState([])
useEffect(() => {
if (window.location.hostname == 'myhost') {
setServiceToUse([require('../public/service/myhost.com.json'])
} else {
setServiceToUse([require('../public/service/default.json')])
}
}, []);
}
You syntax for hooks aren't correct either. Learn more about Hooks
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…