Skip to content
This repository was archived by the owner on May 5, 2023. It is now read-only.
This repository was archived by the owner on May 5, 2023. It is now read-only.

Why are text line breaks wrong? #148

Description

@hristowwe

today i tried this library and i am quite happy. I just didn't understand why the text was going to the new line like that -

image

Why comentssss, sss go to new line? How can i fix that?

My code so far

import React from "react";
import { StyleSheet, Text, TouchableOpacity, View } from "react-native";
import { Cell, Row, Table, TableWrapper } from "react-native-table-component";

export default function App() {
  const tableHead = [
    "I wanted to add that test here componentssss",
    "Head2",
    "Head3",
    "Head4",
  ];
  const tableData = [
    ["1", "2", "3", "4"],
    ["a", "b", "c", "d"],
    ["1", "2", "3", "4"],
    ["a", "b", "c", "d"],
  ];
  const element = (data, index) => (
    <TouchableOpacity onPress={() => alert(index)}>
      <View style={styles.btn}>
        <Text style={styles.btnText}>button</Text>
      </View>
    </TouchableOpacity>
  );
  return (
    <View style={styles.container}>
      <Table borderStyle={{ borderColor: "transparent" }}>
        <Row data={tableHead} style={styles.head} textStyle={styles.text} />
        {tableData.map((rowData, index) => (
          <TableWrapper key={index} style={styles.row}>
            {rowData.map((cellData, cellIndex) => (
              <Cell
                key={cellIndex}
                data={cellIndex === 3 ? element(cellData, index) : cellData}
                textStyle={styles.text}
              />
            ))}
          </TableWrapper>
        ))}
      </Table>
    </View>
  );
}

const styles = StyleSheet.create({
  container: { flex: 1, padding: 16, paddingTop: 30, backgroundColor: "#fff" },
  head: {
    backgroundColor: "#808B97",
  },
  text: { margin: 6, textAlign: "center" },
  row: {
    flexDirection: "row",
    backgroundColor: "#FFF1C1",
  },
  btn: { width: 58, height: 18, backgroundColor: "#78B7BB", borderRadius: 2 },
  btnText: { textAlign: "center", color: "#fff" },
});

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions