我想实现以下功能https://facebook.github.io/react/tips/expose-component-functions.html,但我使用的是ES6语法
@controllable(['center', 'zoom', 'hoverKey', 'clickKey', 'selectedCountry']) export default class ContactMapView extends Component { constructor(props) { super(props); this.initialFunc = this.initialFunc.bind(this); } initialFunc() { … }
当我在父类中调用initialFunc时
componentDidMount() { MapStore.addChangeListener(this._onChange.bind(this)); this.refs['mapView'].initialFunc(); };
我收到以下错误:
TypeError: this.refs.mapView.initialFunc is not a function
任何想法我怎么能运行我的子组件的功能?