如何使用静态方法更新反应组件的属性?

时间:2016-02-26 06:17:39

标签: reactjs typescript redux

我有一个如下所示的组件

interface JoPanelViewProps {
    joSelection?: number;    
}

interface JourneyPanelViewState {
    dateInput?: string;
    jos?: Array<JoModel>;
}

function mapStateToProps(state: TStoreState, ownProps: JoPanelViewProps): JoPanelViewProps {
    const { joSelection } = state;

    return { joSelection };
}

@connect(mapStateToProps, null, null, { pure: true })
class JoPanelView extends React.Component<JoPanelViewProps, JoPanelViewState>{

    private jos: JoModel;

    constructor(props: JoPanelViewProps, context?: any) {
        super(props, context);
        this.state = {
            dateInput:  moment().format('DD/MM/YYYY')
        }
        this.fetchJos(this.props.joSelection);
    }

    private fetchJos(joId:number):void{
        // updates jos to state to trigger render
    }    

}

如何使用静态成员函数将joId更新为此类外部的组件属性?或者我有办法吗?

0 个答案:

没有答案