Basic Blocks
Table

Table

ℹ️

usePreParser hook should be used to fetch all rows of the table.

The backbone of tetra-pack is actually the implementation of table. Tetra-pack divides tables into most basic html tags. All the tags are mentioned below.

Pre-Defined Syntax

	blocks: {
		table: (text, key) => <table key={key}>{text}</table>,
		table_cell: (text, key) => <td key={key}>{text}</td>,
		table_row: (text, key) => <tr key={key}>{text}</tr>,
		table_header_cell: (text, key) => <th key={key}>{text}</th>,
		table_head: (text, key) => <thead key={key}>{text}</thead>,
		table_body: (text, key) => <tbody key={key}>{text}</tbody>,
	}

Table Anatomy

Basic table structure looks like:

	<table>
		// table head
		<thead>
			<tr>
				<th>wrestler</th>
				<th>origin</th>
				<th>finisher</th>
			</tr>
		</thead>
 
		// table body
		<tbody>
			<tr>
				<td>Randy Ortan</td>
				<td>Texas</td>
				<td>RKO</td>
			</tr>
			<tr>
				<td>Steve Cold Austin</td>
				<td>Austin</td>
				<td>Stone Cold Stunner</td>
			</tr>
		</tbody>
	</table>	

All the elements used to construct a table include,

  1. Table Wrapper
    The wrapper tag for all the rows. It is the basic <table /> tag.

    table: (text, key) => <table key={key}>{text}</table>,
  2. Table Simple Cell
    All the data, i.e. the table cells except header cells, are wrapped inside basic <td /> tag.

    table_cell: (text, key) => <td key={key}>{text}</td>,
  3. Table Header Cell
    The data for header row or column is wrapped inside <th /> tag.

    table_header_cell: (text, key) => <th key={key}>{text}</th>,
  4. Table Row
    All the cells of a simple table row are wrapped inside <tr /> tag.

    table_row: (text, key) => <tr key={key}>{text}</tr>,
  5. Table Head
    The Header row of the table is wrapped inside <thead /> tag.

    table_header_cell: (text, key) => <th key={key}>{text}</th>,
  6. Table Body
    All the rows except header row are clubbed together and wrapped inside <tbody /> tag.

    table_header_cell: (text, key) => <th key={key}>{text}</th>,