Skip to content
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

Checking for truthy value of a always true token. #509

Open
sarojregmi200 opened this issue Oct 23, 2024 · 2 comments
Open

Checking for truthy value of a always true token. #509

sarojregmi200 opened this issue Oct 23, 2024 · 2 comments

Comments

@sarojregmi200
Copy link

sarojregmi200 commented Oct 23, 2024

Hey there, thank you for making this library.

I was going through the source code and found out that in RenderTableBody function the data variable which is being checked using a if statement is always true.

The data variable defaults to [] which is truthy value in javascript.

Default value assignment:

data: dataProp = DATA_PLACEHOLDER,

Checking:

if (data) {

I would love to know the reason behind it.
I may be missing a whole lot of context, but I believe this can bring further problems in future updates.

@simonguo
Copy link
Member

In actual business scenarios, it may be null to pass the data returned by the server directly

@sarojregmi200
Copy link
Author

Got it, it's true that it may be null. While that makes complete sense.
Lets say for example if you set data to null it simply errors out and says data is null.

Image:
20241101_21h24m28s_grim

Example code to generate above response:

<Table 
    data={null}
    height={innerHeight}>
    <Column width={60} align="center" fixed>
        <HeaderCell>Id</HeaderCell>
        <Cell dataKey="id" />
    </Column>
</Table>

Or simply use the first example from the docs site and set data to null.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants