简体   繁体   中英

react-table expansion is not working inside popover

I'm using react-table across the site was working fine, I tried to use react-table inside popover the table was displayed but the expansion of row is not working, while checking DOM the expansion click was happening and data was rendered for a fraction of second and gone.

import { OverlayTrigger, Popover } from 'react-bootstrap';
import ReactTable from 'react-table';

export const sampleTable = observer(class sampleTable extends React.Component {
const table = <ReactTable data={tableData} pivotBy={["parent"]} columns={tableColumn}  />
return (<>
<OverlayTrigger className="popover"
 popperConfig={{ modifiers: { preventOverflow: { enabled: false } } }} 
 placement={row.distance < 400 ? "auto" : "left"} 
 trigger="click" rootClose overlay={<Popover>{table}</Popover>}> 
<p>some data </p>
</OverlayTrigger> 
</>);
}

finally found the solution, popover is re-rendering on data change, by default react-table will collapse the row on re-render,avoid that by adding collapseOnDataChange: false

PS: using mobx.js for store

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM