New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
formatExtraData value from state not refreshing #859
Comments
Some snips of code:
|
Well, "solved" my problem this way:
|
I will evolve it to a better "no data yet" handler, but if there is another way to implement something better than the way I did, I will appreciate. Else, this ticket can be closed. |
@lovato https://react-bootstrap-table.github.io/react-bootstrap-table2/docs/column-props.html#columnformatter-function I will not suggest developer to give a state data to If ok, would you please give me a simple and minimal code on codesandbox so that I can help you to see what's kind of issue you face? No rush, thank you btw, https://codesandbox.io/s/jlol04qrxv this is an example you can take and remember to change |
@AllenFang I am also experiencing this issue. Would you mind explaining what is incorrect about the example below? |
hello @jrae26 and @lovato this issue is fixed, please at least to upgrade related package listed below to newest version: https://react-bootstrap-table.github.io/react-bootstrap-table2/blog/2019/03/26/version-bump.html |
I will give it a try, but as I said, I am now waiting till all my ajax calls get 200, and that is the greenlight to render the component. |
I still have this issue with v3.0.3 and v3.1.0 using this sample: Updates to state do not force a rendering of the table even if passed through formatExtraData. However, if you choose to sort a column, that does force a render and displays the updated state data. |
@AllenFang I coded another feature, which led me back to the same issue, on a different Bootstrap Table property.
So, just by clicking here: I understand that my table should refresh, but it doesn't. Is this supposed to be fixed, or I should workaround this in a different way? I mean, I can force-refresh if I find a way to subscribe to globalstate changes, but I don't think this will be correct. Best, |
I'm facing the exact same issue. Can't seem to figure out an effective and efficient workaround either. |
Using "react-bootstrap-table-next": "^3.2.1" in the codesandbox does the trick |
I seem to still be having this issue in ^4.0.6 with my use case. I am passing in a I update the state of the function addNewData(data, state) {
return {
...state,
mapping: new Map([...state.mapping, ...data])
}
} Then I pass |
The library (underscore) that you are using to compare equality for import React from "react";
import _ from "underscore";
import {_ as __} from "lodash";
import "./styles.css";
export default function App() {
const [map1, map2] = [
new Map(),
new Map(
[["hello", "world"], ["works", false]]
)]
return (
<div className="App">
<p>native: {(map1 === map2).toString()}</p>
<p>underscore: {_.isEqual(map1, map2).toString()}</p>
<p>lodash: {__.isEqual(map1, map2).toString()}</p>
</div>
);
} This shows: native: false |
I might have implemented it not on the most perfect way, but it worked for RBTv1.
Why? Because the formatExtraData value was explicitly declared inside render.
With RBTv2, it is just a field on a JSON, and changing the state isn't seen by render().
I make a bunch of ajax calls (up to 3). One is for master tabledata, and others to get descriptions about IDs used on the database table, so I can display names instead of ids.
Since everything is async, it happens to update this side data bucket AFTER rendering, and I keep seeing nothing at table cells (since side-json is empty at this moment).
The trick is (and where I am asking for quick help) that if I do paginate, next page has all my data, and if I go back to page 1, it is sitting there perfectly. But I don't know how to trigger that re-render w/o changing pages.
Long help would be if this is a real problem, and needs to be discussed. My point on this is because using table v1 it was working because it happened to be declared in render on TableHeaderColumn as prop.
The text was updated successfully, but these errors were encountered: