Javascript 警告:函数作为子函数无效

Javascript 警告:函数作为子函数无效,javascript,reactjs,redux,jsx,Javascript,Reactjs,Redux,Jsx,我不明白为什么会出现以下错误。。。任何帮助都将不胜感激 “warning.js:35 warning:函数作为React子函数无效。如果您返回的是组件而不是从render返回,则可能会发生这种情况。或者您可能是想调用此函数而不是返回它。” 这是我的密码: import React from 'react'; import PropTypes from 'prop-types'; import {connect} from 'react-redux'; import ContentTable fr

我不明白为什么会出现以下错误。。。任何帮助都将不胜感激

“warning.js:35 warning:函数作为React子函数无效。如果您返回的是组件而不是从render返回,则可能会发生这种情况。或者您可能是想调用此函数而不是返回它。”

这是我的密码:

import React from 'react';
import PropTypes from 'prop-types';
import {connect} from 'react-redux';
import ContentTable from './ContentTableBuilder';

import {
    setCurrentContentPage,
    setCurrentContent,
    clearContentsAfterPage,
    fetchLicensedContents
} from '../../../../actions/library';

export default () => {

    class SchoolContentList extends React.Component {

        render() {
            const {
                activeInstitution,
                contentType,
                role,
                contentPages,
                fetchLicensedContents,
                setCurrentContentPage,
                setCurrentContent,
                clearContentsAfterPage,
            } = this.props;
            return (
                <div className="contentBox">
                    {/* Main Content Table */}
                    <ContentTable {...{
                        recordPages: contentPages,
                        fetchRecords: (...args) => fetchLicensedContents(contentType, role, activeInstitution.id, ...args),
                        setCurrentRecordPage: setCurrentContentPage,
                        setCurrentRecord: setCurrentContent,
                        clearRecordsAfterPage: clearContentsAfterPage,
                    }} />
                </div>
            );
        }
    }

SchoolContentList.propTypes = {
    role: PropTypes.string.isRequired,
    activeInstitution: PropTypes.shape({
        id: PropTypes.number,
    }).isRequired,
    contentPages: PropTypes.object.isRequired,
    fetchLicensedContents: PropTypes.func.isRequired,
    setCurrentContentPage: PropTypes.func.isRequired,
    setCurrentContent: PropTypes.func.isRequired,
    clearContentsAfterPage: PropTypes.func.isRequired,
};

const mapStateToProps = (state) => {
    const auth = state.auth;
    return {
        role: auth.user.role,
        activeInstitution: auth.institutions.active || {},
        contentPages: state.library.contentPages,
    };
};

const mapDispatchToProps = (dispatch) => ({
    fetchLicensedContents: (contentType, q, page, perPage, sortOpts, extraFilters) => (
        dispatch(fetchLicensedContents(contentType, q, page, perPage, sortOpts, extraFilters))
    ),
    setCurrentContentPage: (page) => dispatch(setCurrentContentPage(page)),
    setCurrentContent: (contentId, data) => dispatch(setCurrentContent(contentId, data)),
    clearContentsAfterPage: (page) => dispatch(clearContentsAfterPage(page)),
});

return connect(
    mapStateToProps,
    mapDispatchToProps
)(SchoolContentList);
};
从“React”导入React;
从“道具类型”导入道具类型;
从'react redux'导入{connect};
从“/ContentTableBuilder”导入ContentTable;
进口{
setCurrentContentPage,
setCurrentContent,
clearContentsAfterPage,
获取许可内容
}来自“../../../../actions/library”;
导出默认值()=>{
类SchoolContentList扩展了React.Component{
render(){
常数{
活动机构,
内容类型,
角色
内容页,
获取许可内容,
setCurrentContentPage,
setCurrentContent,
clearContentsAfterPage,
}=这是道具;
返回(
{/*主内容表*/}
fetchLicensedContents(contentType、role、activeInstitution.id、…args),
setCurrentRecordPage:setCurrentContentPage,
setCurrentRecord:setCurrentContent,
clearRecordsAfterPage:clearContentsAfterPage,
}} />
);
}
}
SchoolContentList.propTypes={
角色:PropTypes.string.isRequired,
活动机构:PropTypes.shape({
id:PropTypes.number,
}).要求,
contentPages:PropTypes.object.isRequired,
fetchLicensedContents:PropTypes.func.isRequired,
setCurrentContentPage:PropTypes.func.isRequired,
setCurrentContent:PropTypes.func.isRequired,
clearContentsAfterPage:PropTypes.func.isRequired,
};
常量mapStateToProps=(状态)=>{
const auth=state.auth;
返回{
角色:auth.user.role,
activeInstitution:auth.institutions.active |{},
contentPages:state.library.contentPages,
};
};
const mapDispatchToProps=(调度)=>({
fetchLicensedContents:(contentType、q、page、perPage、sortOpts、extraFilters)=>(
分派(获取许可内容(contentType、q、page、perPage、sortOpts、extraFilters))
),
setCurrentContentPage:(第页)=>dispatch(setCurrentContentPage(第页)),
setCurrentContent:(contentId,数据)=>dispatch(setCurrentContent(contentId,数据)),
clearContentsAfterPage:(第页)=>dispatch(clearContentsAfterPage(第页)),
});
返回连接(
MapStateTops,
mapDispatchToProps
)(学校目录);
};

好吧,正如警告所说的-您不能导出一个函数,然后将其用作组件(我想您可能会在某个地方这样做)。改为导出组件(在开始时删除箭头功能)

此问题可能来自某个导入的组件。请确保您的组件是按照react文档中的指定创建的。为什么在此处将组件导出为函数?