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.

Issues with borders

See original GitHub issue

Hi, I noticed some strange issues with borders. Sometimes they are not visible at all, sometimes are of different width even if I set the same width to all borders, sometimes they stretch after the end of the View (See image below) screen shot 2018-09-10 at 3 22 48 pm

This is the table component that I made to render tables:

import React from 'react';
import PropTypes from 'prop-types';
import { View, StyleSheet, Text } from '@react-pdf/renderer';

const tableBorderWidth = '1px';
const tableBorderColor = 'grey';

const styles = StyleSheet.create({
    rowsContainer: {
        flex: 0,
        flexDirection: 'column',
        borderTop: `${tableBorderWidth} solid ${tableBorderColor}`
    },
    row: {
        flex: 0,
        flexDirection: 'row',
        borderLeft: `${tableBorderWidth} solid ${tableBorderColor}`,
        borderBottom: `${tableBorderWidth} solid ${tableBorderColor}`
    },
    defaultText: {
        padding: 0,
        fontSize: 7
        // marginTop: 2 // hack to center text vertically,
    },
    defaultCell: {
        paddingVertical: 1,
        paddingHorizontal: 3,
        borderRight: `${tableBorderWidth} solid ${tableBorderColor}`
    }
});

export default class PDFTable extends React.PureComponent {
    renderSingleCell = ({ cellStyle, textStyle, value }, columnIndex) => (
        <View
            key={columnIndex}
            style={[styles.defaultCell, cellStyle, { width: this.props.columnWidths[columnIndex] }]}
        >
            <Text style={[styles.defaultText, textStyle]}>{value}</Text>
        </View>
    );

    renderSingleRow = (row, rowIndex) => {
        return (
            <View key={rowIndex} style={styles.row}>
                {row.map(this.renderSingleCell)}
            </View>
        );
    }

    render = () => {
        return (
            <View style={styles.rowsContainer}>
                {this.props.rows.map(this.renderSingleRow)}
            </View>
        );
    }
}

const CellShape = PropTypes.shape({
    cellStyle: PropTypes.objectOf(PropTypes.any),
    textStyle: PropTypes.objectOf(PropTypes.any),
    value: PropTypes.oneOfType([PropTypes.number, PropTypes.string])
});

PDFTable.propTypes = {
    columnWidths: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.number, PropTypes.string])),
    rows: PropTypes.arrayOf(PropTypes.arrayOf(CellShape)).isRequired
};

Btw, I was only able to set border in pixels, is there any other unit I can use to define border? Thanks.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
klis87commented, May 14, 2019

@diegomura I also confirm it. see table example here: https://codesandbox.io/s/6xzq3rw8rk

0reactions
jani789commented, Dec 24, 2020

increase table height

Read more comments on GitHub >

github_iconTop Results From Across the Web

Everyone can now agree -- the US has a border crisis - CNN
Amid growing concerns that large groups of migrants waiting in Mexico could cross over the border next week, Biden's team said Thursday it ......
Read more >
What's happening at the U.S.-Mexico border in 7 charts
In Ecuador, widespread economic problems and the COVID-19 pandemic have led many migrants to make the journey north.
Read more >
Border Issues | Wilson Center
Key law enforcement efforts to counter transnational crime occur in the border region, and the nature of border ecosystems, which ignore national boundaries, ......
Read more >
Taking Migration Seriously: Real Solutions to Complex ...
Taking Migration Seriously: Real Solutions to Complex Challenges at the Border · New drivers of migration in the Western Hemisphere require ...
Read more >
Immigration Border Crisis - NBC News
The decision comes as border towns' resources are overwhelmed and local migrant shelters are at capacity.
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