(0, _hoc.default) is not a function. Require cycles are allowed, but can result in uninitialized values

250 views Asked by At

Here is my error went create a HOC use function component instead of class Component

Require cycles are allowed, but can result in uninitialized values. Consider refactoring to remove the need for a cycle.
    [Fri Oct 16 2020 24:17:29.696]  ERROR    TypeError: (0, _hoc.default) is not a function. (In '(0, _hoc.default)(BankingOnline)', '(0, _hoc.default)' is undefined)
    [Fri Oct 16 2020 24:17:29.696]  ERROR    Invariant Violation: Module AppRegistry is not a registered callable module (calling runApplication)
    [Fri Oct 16 2020 24:17:29.696]  ERROR    Invariant Violation: Module AppRegistry is not a registered callable module (calling runApplication)
    [Fri Oct 16 2020 24:17:29.697]  ERROR    Invariant Violation: Module AppRegistry is not a registered callable module (calling runApplication)

my code:

import React, { useState, useContext, useEffect } from "react";
import HeaderComponent from '../../components/header';
import { StoreContext } from '../../store';
import NotAuthView from '../../components/notAuth-view'


const RequiredAuth = (Component) => props => {
    const { authFlag } = useContext(StoreContext)
    if (!authFlag) {
        return <NotAuthView />
    }

    return <Component {...props} />
}

export default RequiredAuth

Anybody have an idea to fix this? Thanks very much!

1

There are 1 answers

0
Dung Nguyen On

I has been solved this problem! Thanks to @lissettdm and @Viet Dinh. This is problem went i use RequiredAuth wrong way.