Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/reactjs/27.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 有没有人有一个;ReferenceError:未定义React“;在角色及;创建Strapi API后的权限?_Javascript_Reactjs_Strapi - Fatal编程技术网

Javascript 有没有人有一个;ReferenceError:未定义React“;在角色及;创建Strapi API后的权限?

Javascript 有没有人有一个;ReferenceError:未定义React“;在角色及;创建Strapi API后的权限?,javascript,reactjs,strapi,Javascript,Reactjs,Strapi,直到今天我才有任何问题。我想创建一个新的Strapi API,但我总是得到一个 ReferenceError: React is not defined 在角色和权限设置菜单中,当我要修改角色时。 角色如下: 但当我试图修改其中一个时,我得到了: 我尝试创建一个应用程序与纱线和npx。他们两人的结果是一样的。我还尝试用sqlite和postgres创建它 我可以补充一点,我的老一代API仍然正常工作 Strapi版本:3.0.3从复制解决方案 大家好,有一个公开的公关解决了这个问题,我们真

直到今天我才有任何问题。我想创建一个新的Strapi API,但我总是得到一个

ReferenceError: React is not defined
在角色和权限设置菜单中,当我要修改角色时。 角色如下:

但当我试图修改其中一个时,我得到了:

我尝试创建一个应用程序与纱线和npx。他们两人的结果是一样的。我还尝试用sqlite和postgres创建它

我可以补充一点,我的老一代API仍然正常工作

Strapi版本:3.0.3

从复制解决方案

大家好,有一个公开的公关解决了这个问题,我们真的很抱歉这个问题,它不应该发生。在此期间,在发布之前,这里有一个让您的管理工作正常的变通方法:

创建一个扩展名/users permissions/admin/src/components/Controller/index.js文件:

mkdir -p extensions/users-permissions/admin/src/components/Controller
touch extensions/users-permissions/admin/src/components/Controller/index.js
/**
 *
 * Controller
 *
 */
import React from 'react';
import PropTypes from 'prop-types';
import { get, map } from 'lodash';
import { FormattedMessage } from 'react-intl';
import pluginId from '../../pluginId';
import { useEditPageContext } from '../../contexts/EditPage';
import InputCheckbox from '../InputCheckboxPlugin';

import { Header, Label, Separator, Wrapper } from './Components';

function Controller({ actions, inputNamePath, isOpen, name, inputSelected, setInputSelected }) {
  const { selectAllActions } = useEditPageContext();

  const areAllActionsSelected = () => {
    return Object.keys(actions).every(action => actions[action].enabled === true);
  };

  const handleChange = () => {
    selectAllActions(`${inputNamePath}.controllers.${name}`, !areAllActionsSelected());
  };

  const hasSomeActionsSelected = () => {
    return Object.keys(actions).some(action => actions[action].enabled === true);
  };

  const setNewInputSelected = name => {
    setInputSelected(name);
  };

  const labelId = areAllActionsSelected() ? 'unselectAll' : 'selectAll';

  return (
    <Wrapper>
      <Header>
        <div>{name}</div>
        <Separator />
        <div className="checkbox-wrapper">
          <div className="form-check">
            <Label
              className={`form-check-label ${areAllActionsSelected() &&
                'checked'} ${!areAllActionsSelected() &&
                hasSomeActionsSelected() &&
                'some-checked'}`}
              htmlFor={name}
            >
              <input
                className="form-check-input"
                checked={areAllActionsSelected()}
                id={name}
                name={name}
                onChange={handleChange}
                type="checkbox"
              />
              <FormattedMessage id={`${pluginId}.Controller.${labelId}`} />
            </Label>
          </div>
        </div>
      </Header>
      <div className="row">
        {map(Object.keys(actions).sort(), actionKey => (
          <InputCheckbox
            inputSelected={inputSelected}
            isOpen={isOpen}
            key={actionKey}
            label={actionKey}
            name={`${inputNamePath}.controllers.${name}.${actionKey}.enabled`}
            setNewInputSelected={setNewInputSelected}
            value={get(actions[actionKey], 'enabled')}
          />
        ))}
      </div>
    </Wrapper>
  );
}

Controller.defaultProps = {
  actions: {},
  inputNamePath: 'permissions.application',
  name: '',
};

Controller.propTypes = {
  actions: PropTypes.object,
  inputNamePath: PropTypes.string,
  isOpen: PropTypes.bool.isRequired,
  name: PropTypes.string,
};

export default Controller;
复制以下内容:

mkdir -p extensions/users-permissions/admin/src/components/Controller
touch extensions/users-permissions/admin/src/components/Controller/index.js
/**
 *
 * Controller
 *
 */
import React from 'react';
import PropTypes from 'prop-types';
import { get, map } from 'lodash';
import { FormattedMessage } from 'react-intl';
import pluginId from '../../pluginId';
import { useEditPageContext } from '../../contexts/EditPage';
import InputCheckbox from '../InputCheckboxPlugin';

import { Header, Label, Separator, Wrapper } from './Components';

function Controller({ actions, inputNamePath, isOpen, name, inputSelected, setInputSelected }) {
  const { selectAllActions } = useEditPageContext();

  const areAllActionsSelected = () => {
    return Object.keys(actions).every(action => actions[action].enabled === true);
  };

  const handleChange = () => {
    selectAllActions(`${inputNamePath}.controllers.${name}`, !areAllActionsSelected());
  };

  const hasSomeActionsSelected = () => {
    return Object.keys(actions).some(action => actions[action].enabled === true);
  };

  const setNewInputSelected = name => {
    setInputSelected(name);
  };

  const labelId = areAllActionsSelected() ? 'unselectAll' : 'selectAll';

  return (
    <Wrapper>
      <Header>
        <div>{name}</div>
        <Separator />
        <div className="checkbox-wrapper">
          <div className="form-check">
            <Label
              className={`form-check-label ${areAllActionsSelected() &&
                'checked'} ${!areAllActionsSelected() &&
                hasSomeActionsSelected() &&
                'some-checked'}`}
              htmlFor={name}
            >
              <input
                className="form-check-input"
                checked={areAllActionsSelected()}
                id={name}
                name={name}
                onChange={handleChange}
                type="checkbox"
              />
              <FormattedMessage id={`${pluginId}.Controller.${labelId}`} />
            </Label>
          </div>
        </div>
      </Header>
      <div className="row">
        {map(Object.keys(actions).sort(), actionKey => (
          <InputCheckbox
            inputSelected={inputSelected}
            isOpen={isOpen}
            key={actionKey}
            label={actionKey}
            name={`${inputNamePath}.controllers.${name}.${actionKey}.enabled`}
            setNewInputSelected={setNewInputSelected}
            value={get(actions[actionKey], 'enabled')}
          />
        ))}
      </div>
    </Wrapper>
  );
}

Controller.defaultProps = {
  actions: {},
  inputNamePath: 'permissions.application',
  name: '',
};

Controller.propTypes = {
  actions: PropTypes.object,
  inputNamePath: PropTypes.string,
  isOpen: PropTypes.bool.isRequired,
  name: PropTypes.string,
};

export default Controller;

今天遇到了同样的问题

有一个最新版本v3.0.4,其中包含了此错误的修复


您找到问题所在了吗?我有完全相同的问题:/btw,我的Strapi版本:3.0.3