Running into a '__resizeListeners__' of undefined with react and Semantic-UI accordion

◇◆丶佛笑我妖孽 提交于 2019-12-14 03:15:37

问题


I am using Semantic-UI accordion for the Segment react component that is wrapped around an eCharts line plot (using echarts-for-react). I currently have a button that allows me to collapse the line plot, as seen in the "collapsed" variable.

I also have a button that allows me to change the size of the component from half screen to full screen.

The problem is when the component is already "collapsed" and I trigger the resize from half screen to full screen then "uncollapse" the component, the chart does not resize to the new container size.

Uncaught TypeError: Cannot read property 'resizeListeners' of undefined

The resize does work when the line plot is not collapsed though.

class PlotSegmentsList extends Component {
   //no life cycle methods yet
  render() {
    const state = store.getState();
    const view = state.fullOrHalfScreen;

    const activeCategory = this.props.categories.find(p => p.category === this.props.Id);
    const activePlotsArray = activeCategory.plots;

    const plotsList = activePlotsArray.map((p) => (
      <div key={p.titles.main} className='column'>
       <Segment 
        legend={p.legend} 
        plotTitles={p.titles} 
      />
       <div className="ui divider"></div>
      </div>      
      )
    );

    return (
      <div className={view === 'half' ? "ui two column grid" : "ui one column grid"}> 
        {plotsList}
      </div>
    )
  }
}

class Segment extends Component {

  render () {    
    const state = store.getState();
    const collapsed = state.collapseOrUncollapseAll;

    return (
      <div>
        <div className="ui fluid accordion">
          <div className="title active">
            <i className="dropdown icon"></i>
              {this.props.plotTitles.main} 
          </div>
          <div className={collapsed? "content active" : "content hidden"}>
            <Toolbar plot_ID={this.props.plotTitles.main}/>
            <Plot 
              data={this.props.data}
              legend={this.props.names}
              plotType='line'
              plotTitles={this.props.plotTitles}
            />
          </div>
        </div>
      </div>

class Plot extends React.Component {

I have tried to add event listeners to Plot in the components lifeCycle methods but I am pretty new to react and redux and unsure how to properly update this components size if it is collapsed in the accordion. Any suggestions on this problem and using react life cycle methods with redux would be great! Thank you


回答1:


I am the author of echarts-for-react.

Upgrade to the latest version of package, can solve the problem above by switching element-size-listener to size-sensor.



来源:https://stackoverflow.com/questions/49634759/running-into-a-resizelisteners-of-undefined-with-react-and-semantic-ui-acc

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!