I'm trying to use antd's Table component in 18.1.0 to no avail, even though I can successfully in version 17

Viewed 200

I'm trying to use ant design table in 18.1.0. However I can't get the table to render when I use it as prescribed in the documentation

<Table columns={columns} dataSource={data} />

I've ruled out all of the obvious things (I did use columns and data earlier when grabbing the data from the API, etc.)

I'm actually getting no errors at all when running it in localhost (npm start launches fine, no browser or VS code terminal warnings or errors), it's just not rendering.

If I put something else like 'testing' in the return for that table component, it renders just fine. I think I've narrowed it dow to the difference between react 17 and 18 versions:

it'll work in 17.x.x. using ReactDOM.render in index.js (that's literally the only change between the code I have in 17 vs 18, the component's code is identical in both).

but I can't use ReactDOM.render in 18. when I tried it, it shows error that 18 doesn't support ReactDOM.render ).so it seems I have to use 18's way of rendering?:

const root = ReactDOM.createRoot(document.getElementById('root'));

root.render

But again, it won't render antd's table comp data. I have no clue how to fix. I assume I somehow need to change 18's index.js so it'll render data from antd's table comp?

Any ideas are much appreciated.

0 Answers
Related