react-tabulator
react-tabulator copied to clipboard
Props used in cellEdited function are different to those shown in Devtools at runtime
**Title props used in cellEdited function are different to those shown in Devtools at runtime **
- bug/misunderstanding: props used in cellEdited function are different to those shown in Devtools at runtime
Environment Details
- react-tabulator version: 0.12.7
- OS: windows 10
- Node.js version: 12
Long Description I have a state variable projectNumber that is contained in my parent element. The child elements are the Tabulator component (containing the react tabulator table), and a Footer component containing a carousel of projects which are clickable in order to change the parent projectNumber state (see screenshot)
I have a useEffect function in the Tabulator component which listens for changes in the props.projectNumber, hits my API endpoint for that project number and returns data to fill in the ReactTabulator Constructor like so:
useEffect(() => {
const fetchData = async () => {
// hit endpoint and update data state variable in Tabulator component
}
fetchData();
}, [props.projectNumber]);
<ReactTabulator
style={{ paddingTop: `25px` }}
data={state.data}
columns={stagesColumns}
history={true}
options={options}
tooltips={true}
layout={"fitData"}
cellEdited={cellEdited}
/>
This all seems to work fine with the table data updating on each project click in the Footer and the updated project number shown in devtools both as parent state and as props in the Tabulator component. The problem arises when I try to edit the data in the table. The cellEdited function also reads the value of props.projectNumber, in order to know which project to update. However, when I print the value of props.projectNumber inside the cellEdited function, the value is actually the initial state value (not the expected value shown in DevTools). I notice that if I change the projectNumber state variable, then go backwards one page then forwards one page in the router, that the cellEdited then reads the correct value.
Am I missing something simple here? Thanks in advance for any help you can give
Hello! I am also having this problem
i am also getting same issue