question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to render custom component in DataTable.Cell

See original GitHub issue

I’m trying to create a table with a button in the last column. But, when I add something different than a text node I get this error:

Cannot add a child that doesn't have a YogaNode to a parent withou a measure function!

So, this is working:

<DataTable.Cell>Test</DataTable.Cell>

But this is not:

<DataTable.Cell children={<Button>Test</Button>} />

// neither this
<DataTable.Cell>
  <Button>Test</Button>
</DataTable.Cell>

Am I doing something wrong?


Package Version
react 16.11.0
react-native 0.62.2
react-native-paper 3.10.1

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:4
  • Comments:5

github_iconTop GitHub Comments

2reactions
12343954commented, Jun 12, 2020

same issus +1 DataTable.Cell didn’t support children component yet. 3.10.1

but here is a solution :

Just render a view. You don’t need to wrap it in DataTable.Cell https://github.com/callstack/react-native-paper/issues/1038#issuecomment-488248046

0reactions
ConjuringCoffeecommented, Sep 18, 2022

You can use a View instead of DataTable.Cell. Here’s an example:

<DataTable.Row>
    <DataTable.Cell>Stuff</DataTable.Cell>
    <View>
        <IconButton
            icon='information-outline'
            onPress={() => console.log('Hello World')} />
    </View>
</DataTable.Row>

EDIT: To make this look good, you need to add some styles too. If you want, you can replicate the style used by the DataTable.Cell.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Column rendering - DataTables example
Each column has an optional rendering control called columns.render which can be used to process the content of each cell before the data...
Read more >
lightning-datatable with custom cell and component mutates Id ...
What's happening is that you're assigning the value to this, so it gets modified during rendering. To fix this, use a different attribute...
Read more >
Customizing the Lightning Datatable Component
You can implement a custom cell, such as a delete-a-row button or image. The lightning-datatable component supports both standard data types ...
Read more >
react-table render component inside data - Stack Overflow
You're passing a react component to a data field that expects a string. Try customising your cell via Cell props:
Read more >
Building a Data Table Component in React — Development
Add className=”Cell-fixed” to the first cell of each row. The component maps through each row (and not each column) so, for simplicity, we...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found