Avevo bisogno di rifattorizzare il mio componente funzionale stateless in una classe. Quando l'ho fatto, continuo a ricevere un errore in cui sembra che React stesso non sia definito.Uncaught (promessa) TypeError: Impossibile leggere la proprietà 'createElement' di undefined (...)
import React from 'react';
import { Cell } from 'fixed-data-table';
const DataCell = ({rowIndex, columnKey, data, onMessageClicked, ...props}) => {
return (
<Cell {...props} onClick={onMessageClicked(data[rowIndex].Id)}>
{data[rowIndex][columnKey]}
</Cell>
);
};
export default DataCell;
a
import { React, Component } from 'react';
import { Cell } from 'fixed-data-table';
class DataCell extends Component {
onCellClicked() {
this.props.onMessageClicked(this.props.data[this.props.rowIndex].Id);
}
render() {
const {rowIndex, columnKey, data, ...props} = this.props;
return (
<Cell {...props} onClick={onCellClicked}>
{data[rowIndex][columnKey]}
</Cell>
);
}
}
export default DataCell;
bundle.js:43248 Uncaught (in promise) TypeError: Cannot read property 'createElement' of undefined(…)
e quando vado a quella linea vedo
return _react.React.createElement(
io non capisco. Come faccio a eseguire il debug/risolvere questo problema?
Il mio codice completo per questa app è here nel caso in cui il codice che sto postando non sia collegato in qualche modo.
Grazie!
ancora utile oggi, era un po 'una testa-scratcher. Grazie! – Mtz