TypeError: rules.map 不是一个函数 - React js



正在尝试对以下内容运行单元测试:这是一段代码:

    renderAdvancedColumns = () => {
let rules = this.props.selectedFormJSON ? this.props.selectedFormJSON.FORM_RULE : [];
let inner = [];
if(rules.length !== 0) {
  inner = rules.map((rule, i) => { //LINE GIVING ERROR
    return (
      <div className={i===0? 'settings-field first-form-field' : 'settings-field'}>
      <div className='settings-label'>
        {rule.Event}
        <div 
          className={this.props.selectedFormJSON.FORM_RULE[i].FORM_OPERATION.HttpMethod !== 'POST' && 
            this.props.selectedFormJSON.FORM_RULE[i].FORM_OPERATION.HttpMethod !== 'PATCH' ? 
            'tran-button specify-body-button disabled' : 'tran-button specify-body-button'} 
          disabled={this.props.selectedFormJSON.FORM_RULE[i].FORM_OPERATION.HttpMethod === 'GET'}
          onClick={()=>{this.setState({specifyBodyModalOpen: true})}}>
          Specify Body
        </div>
      </div>
      <input className='settings-input' value={this.props.selectedFormJSON.FORM_RULE[i].FORM_OPERATION.Endpoint || ''} onChange={(e) => {this.updateFORMOPERATION(i, 'Endpoint', e.target.value)}} />

我通常会启动我的测试文件,并确保它们都正确渲染。但不确定为什么这会阻塞:内部 = rules.map((rule, i( => {

这是我如何声明这个.props

const baseProps = {
 selectedFormJSON :{
  Subform:{},
 SubformFilter:{},
 OverlayMapper:{},
 Name:{},
 Form_UID:{},
 FORM_RULE:{
 FORM_OPERATION:{
 Endpoint:{},
 HttpMethod:{},
 },
},

  Describe('FormSettings ', () => {
 let wrapper;
 let tree;
 it('should render using all of the props', () => {  
tree = renderer.create(<BrowserRouter><FormSettings {...baseProps} /> 
 </BrowserRouter>)
let treeJson = tree.toJSON()
expect(treeJson).toMatchSnapshot();
tree.unmount()
});

selectedFormJSON.FORM_RULE是一个对象

不能在对象上使用映射。