react-bootstrap-table
とcellEdit
を有効にしています。セルが編集された後でreact-bootstrap-table
にコールバック関数を使用することは可能です。コールバック関数の名前はonAfterSaveCell
です。テーブルの更新された行は、row
という変数に保存されます。 row
を入力として受け入れるpushData
というアクション作成者にrow
を送付したいと思います。私のコードはこのように見えます。クラス外の小道具にアクセス
function onAfterSaveCell(row, cellName, cellValue){
this.props.pushData(row);
}
const cellEditProp = {
mode: "click",
blurToSave: true,
afterSaveCell: onAfterSaveCell
};
class Feature extends Component {
componentWillMount() {
this.props.fetchMessage();
}
render() {
if (!this.props.message) return null
return (
<div>
<BootstrapTable
data={this.props.message}
cellEdit={cellEditProp}
>
<TableHeaderColumn dataField="ccyCode" isKey={true} dataSort={true}>Valutakod</TableHeaderColumn>......
私はエラーUncaught TypeError: Cannot read property 'props' of undefined
コードを実行します。私が考えているのはprops
はclass Feature
の外では利用できません。私はonAfterSaveCell
ファンクションでcellEditProp
に移動しようとしましたが、class Feature
にコンパイルエラーが発生します。 props
をclass Feature
の外部からアクセスできるようにするにはどうすればよいですか、これは他の方法で解決する必要がありますか?