<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Nick</title>
    <description>The latest articles on Forem by Nick (@fromaline).</description>
    <link>https://forem.com/fromaline</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F655830%2F82a98154-0980-42e8-a60f-4698a5db83b6.png</url>
      <title>Forem: Nick</title>
      <link>https://forem.com/fromaline</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/fromaline"/>
    <language>en</language>
    <item>
      <title>Block Time</title>
      <dc:creator>Nick</dc:creator>
      <pubDate>Thu, 21 Dec 2023 15:46:34 +0000</pubDate>
      <link>https://forem.com/chainspect_app/block-time-2p98</link>
      <guid>https://forem.com/chainspect_app/block-time-2p98</guid>
      <description>&lt;h2&gt;
  
  
  Block Time of the most popular blockchains
&lt;/h2&gt;

&lt;p&gt;Block time differs for every blockchain. Some allow faster block times than others. Depending on the blockchain, a new block can be mined in a matter of seconds, or it can take a few minutes.&lt;/p&gt;

&lt;p&gt;Here are the Block Time metrics for the most popular blockchains. These metrics are relevant on Feb 12, 2024. For real-time metrics check out &lt;a href="https://chainspect.app/dashboard" rel="noopener noreferrer"&gt;our dashboard&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://chainspect.app/chain/algorand" rel="noopener noreferrer"&gt;Algorand&lt;/a&gt; block time is 2.87s&lt;br&gt;&lt;br&gt;
&lt;a href="https://chainspect.app/chain/arbitrum" rel="noopener noreferrer"&gt;Arbitrum&lt;/a&gt; block time is 0.25s&lt;br&gt;&lt;br&gt;
&lt;a href="https://chainspect.app/chain/avalanche" rel="noopener noreferrer"&gt;Avalanche&lt;/a&gt; block time is 2.01s&lt;br&gt;&lt;br&gt;
&lt;a href="https://chainspect.app/chain/base" rel="noopener noreferrer"&gt;Base&lt;/a&gt; block time is 2s&lt;br&gt;&lt;br&gt;
&lt;a href="https://chainspect.app/chain/bitcoin" rel="noopener noreferrer"&gt;Bitcoin&lt;/a&gt; block time is 5m 58s&lt;br&gt;&lt;br&gt;
&lt;a href="https://chainspect.app/chain/bnb-chain" rel="noopener noreferrer"&gt;BNB Chain&lt;/a&gt; block time is 3s&lt;br&gt;&lt;br&gt;
&lt;a href="https://chainspect.app/chain/bnb-greenfield" rel="noopener noreferrer"&gt;BNB Greenfield&lt;/a&gt; block time is 2.61s&lt;br&gt;&lt;br&gt;
&lt;a href="https://chainspect.app/chain/celo" rel="noopener noreferrer"&gt;Celo&lt;/a&gt; block time is 5s&lt;br&gt;&lt;br&gt;
&lt;a href="https://chainspect.app/chain/cronos" rel="noopener noreferrer"&gt;Cronos&lt;/a&gt; block time is 5.64s&lt;br&gt;&lt;br&gt;
&lt;a href="https://chainspect.app/chain/crust" rel="noopener noreferrer"&gt;Crust&lt;/a&gt; block time is 12.56s&lt;br&gt;&lt;br&gt;
&lt;a href="https://chainspect.app/chain/ethereum" rel="noopener noreferrer"&gt;Ethereum&lt;/a&gt; block time is 12.04s&lt;br&gt;&lt;br&gt;
&lt;a href="https://chainspect.app/chain/fantom" rel="noopener noreferrer"&gt;Fantom&lt;/a&gt; block time is 1.49s&lt;br&gt;&lt;br&gt;
&lt;a href="https://chainspect.app/chain/gnosis" rel="noopener noreferrer"&gt;Gnosis Chain&lt;/a&gt; block time is 5.25s&lt;br&gt;&lt;br&gt;
&lt;a href="https://chainspect.app/chain/hedera" rel="noopener noreferrer"&gt;Hedera&lt;/a&gt; block time is 2s&lt;br&gt;&lt;br&gt;
&lt;a href="https://chainspect.app/chain/integritee" rel="noopener noreferrer"&gt;Integritee&lt;/a&gt; block time is 12.33s&lt;br&gt;&lt;br&gt;
&lt;a href="https://chainspect.app/chain/iotex" rel="noopener noreferrer"&gt;IoTeX&lt;/a&gt; block time is 5s&lt;br&gt;&lt;br&gt;
&lt;a href="https://chainspect.app/chain/opbnb" rel="noopener noreferrer"&gt;opBNB&lt;/a&gt; block time is 1s&lt;br&gt;&lt;br&gt;
&lt;a href="https://chainspect.app/chain/optimism" rel="noopener noreferrer"&gt;Optimism&lt;/a&gt; block time is 2s&lt;br&gt;&lt;br&gt;
&lt;a href="https://chainspect.app/chain/polkadex" rel="noopener noreferrer"&gt;Polkadex&lt;/a&gt; block time is 12s&lt;br&gt;&lt;br&gt;
&lt;a href="https://chainspect.app/chain/polkadot" rel="noopener noreferrer"&gt;Polkadot&lt;/a&gt; block time is 6.03s&lt;br&gt;&lt;br&gt;
&lt;a href="https://chainspect.app/chain/polygon" rel="noopener noreferrer"&gt;Polygon&lt;/a&gt; block time is 2.13s&lt;br&gt;&lt;br&gt;
&lt;a href="https://chainspect.app/chain/scroll" rel="noopener noreferrer"&gt;Scroll&lt;/a&gt; block time is 3s&lt;br&gt;&lt;br&gt;
&lt;a href="https://chainspect.app/chain/sirius" rel="noopener noreferrer"&gt;Sirius&lt;/a&gt; block time is 15.07s&lt;br&gt;&lt;br&gt;
&lt;a href="https://chainspect.app/chain/solana" rel="noopener noreferrer"&gt;Solana&lt;/a&gt; block time is 0.42s&lt;br&gt;&lt;br&gt;
&lt;a href="https://chainspect.app/chain/starknet" rel="noopener noreferrer"&gt;Starknet&lt;/a&gt; block time is 32.82s&lt;br&gt;&lt;br&gt;
&lt;a href="https://chainspect.app/chain/telos" rel="noopener noreferrer"&gt;Telos&lt;/a&gt; block time is 0.5s&lt;br&gt;&lt;br&gt;
&lt;a href="https://chainspect.app/chain/tron" rel="noopener noreferrer"&gt;Tron&lt;/a&gt; block time is 3s&lt;br&gt;&lt;br&gt;
&lt;a href="https://chainspect.app/chain/zeitgeist" rel="noopener noreferrer"&gt;Zeitgeist&lt;/a&gt; block time is 12.3s &lt;/p&gt;




&lt;p&gt;&lt;a href="https://chainspect.app/" rel="noopener noreferrer"&gt;Website&lt;/a&gt; | &lt;a href="https://twitter.com/chainspect_app" rel="noopener noreferrer"&gt;Twitter&lt;/a&gt; | &lt;a href="https://discord.com/invite/nnmJf56XYU" rel="noopener noreferrer"&gt;Discord&lt;/a&gt;&lt;/p&gt;

</description>
      <category>blockchain</category>
      <category>performance</category>
      <category>web3</category>
      <category>cryptocurrency</category>
    </item>
    <item>
      <title>Why Hedera has the highest TPS on Chainspect?</title>
      <dc:creator>Nick</dc:creator>
      <pubDate>Fri, 17 Nov 2023 15:47:17 +0000</pubDate>
      <link>https://forem.com/fromaline/why-hedera-has-the-highest-tps-on-chainspect-1io4</link>
      <guid>https://forem.com/fromaline/why-hedera-has-the-highest-tps-on-chainspect-1io4</guid>
      <description>&lt;p&gt;To understand how &lt;a href="https://chainspect.app/chain/hedera" rel="noopener noreferrer"&gt;Hedera&lt;/a&gt; handles so many transactions per second, we will start with the Scalability Trilemma. In the blockchain space, Scalability Trilemma is a common concept. It revolves around the belief that blockchain can only have two of three benefits at any given time: decentralization, security, and scalability. It means that any improvement in one of the areas will result in deterioration in two other areas. It’s one of the main problems in blockchain space, which many great minds aim to solve.&lt;/p&gt;

&lt;p&gt;Let’s dive deeper into each component of the Scalability Trilemma:&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Decentralization
&lt;/h2&gt;

&lt;p&gt;Decentralization is one of the core value propositions of the blockchain technology. It simply means the decision-making process is not bound to any single entity. You can think of it in the context of countries: there are democratic countries — decentralized ones and countries run by kings and dictators — centralized. The level of decentralization depends on the number of entities participating in the decision-making process, the weight of their vote, and the level of trust that participants must place in one another.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. Security
&lt;/h2&gt;

&lt;p&gt;Any blockchain network consists of numerous software components and consensus algorithm. Blockchain security includes standard software security practices and defense from blockchain-specific attacks: &lt;a href="https://cointelegraph.com/news/identify-and-protect-against-routing-attacks-in-the-lightning-network" rel="noopener noreferrer"&gt;Routing attack&lt;/a&gt;, &lt;a href="https://www.imperva.com/learn/application-security/sybil-attack/#:~:text=The%20main%20goal%20of%20a,affect%20operations%20are%20voted%20on." rel="noopener noreferrer"&gt;Sybil attack&lt;/a&gt;, &lt;a href="https://www.investopedia.com/terms/1/51-attack.asp" rel="noopener noreferrer"&gt;51% attack&lt;/a&gt;. The main point of blockchain attacks is to overtake the consensus mechanism to control the order and content of blocks. These attacks are more probable if the number of nodes producing blocks is low.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Scalability
&lt;/h2&gt;

&lt;p&gt;Scalability indicates the blockchain’s ability to support high transactional throughput and future growth. This means that as the number of users and use cases increases, the performance of the blockchain won’t suffer. Blockchains that perform poorly as adoption increases are said to lack scalability. The Scalability Trilemma tells us that greater scalability is possible, but security, decentralization, or both, will suffer as a consequence.&lt;/p&gt;

&lt;h2&gt;
  
  
  So why is &lt;a href="https://chainspect.app/chain/hedera" rel="noopener noreferrer"&gt;Hedera&lt;/a&gt; transactions per second metric so high?
&lt;/h2&gt;

&lt;p&gt;The answer to this question lies in Hedera’s architecture. Hedera is a public network that utilizes &lt;a href="https://hedera.com/learning/hedera-hashgraph/what-is-hashgraph-consensus?" rel="noopener noreferrer"&gt;a hashgraph consensus algorithm&lt;/a&gt;. Unlike a traditional blockchain, which selects a single miner/validator to choose the next block, the community of nodes running hashgraph comes to an agreement on which transactions to add to the ledger as a collective. Through &lt;a href="https://hedera.com/learning/hedera-hashgraph/what-is-gossip-about-gossip" rel="noopener noreferrer"&gt;gossip-about-gossip&lt;/a&gt; and virtual voting, the hashgraph network comes to a consensus on both the validity and the consensus timestamp of every transaction.&lt;/p&gt;

&lt;p&gt;In blockchain, consensus rules require that blocks eventually settle in a single, longest chain, agreed upon by the community. In hashgraph, every container of transactions is incorporated into the ledger — none are discarded. All the branches continue to exist forever and are woven together into a single whole.&lt;/p&gt;




&lt;p&gt;Check out &lt;a href="https://chainspect.app/dashboard/tps" rel="noopener noreferrer"&gt;chainspect.app dahsboard&lt;/a&gt; to find out real-time TPS for Hedera and 18 more chains!&lt;/p&gt;

</description>
      <category>blockchain</category>
      <category>hedera</category>
      <category>performance</category>
      <category>tps</category>
    </item>
    <item>
      <title>Transactions Per Second (TPS)</title>
      <dc:creator>Nick</dc:creator>
      <pubDate>Wed, 08 Nov 2023 13:04:42 +0000</pubDate>
      <link>https://forem.com/fromaline/transaction-per-second-tps-3f8b</link>
      <guid>https://forem.com/fromaline/transaction-per-second-tps-3f8b</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;In the blockchain world, transactions per second (TPS) metrics measure the number of transactions a blockchain can process in a second.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;There are 3 most common types of TPS:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Real-time TPS&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Max Recorded TPS&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Max Theoretical TPS&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Real-time TPS
&lt;/h2&gt;

&lt;p&gt;Real-time TPS shows how many transactions per second the blockchain is processing. It’s probably the most important of all three metrics because it is based on real-time blockchain data and can’t be inflated. It shows the adoption level of the blockchain and its actual throughput.&lt;/p&gt;

&lt;h2&gt;
  
  
  Max Recorded TPS
&lt;/h2&gt;

&lt;p&gt;Max recorded TPS indicates the peak TPS blockchain has ever reached. It shows how many transactions a blockchain can process during times of high workload. Typically, it happens when the market is volatile, and a lot of people want to transact at the same time.&lt;/p&gt;

&lt;h2&gt;
  
  
  Max Theoretical TPS
&lt;/h2&gt;

&lt;p&gt;Max theoretical TPS shows how many transactions per second the blockchain is theoretically capable of handling. To calculate this metric, divide the block size measured in gas or bytes by the size of the smallest transaction possible. In most blockchains, the least possible transaction is a transfer of a native token.&lt;/p&gt;

&lt;p&gt;For example, the Ethereum block size is 30 million gas, the block time is 12 seconds, and the transfer of Ether takes 21,000 of gas. It means each block can contain 30 million / 21,000 = 1428 transactions. So, the maximum theoretical TPS is 1428 transactions / 12s = 119 transactions per second. Of course, the reality is often different due to the different block times, block sizes, and other real-world nuances.&lt;/p&gt;

&lt;h2&gt;
  
  
  TPS metrics of the most popular blockchains
&lt;/h2&gt;

&lt;p&gt;The following metrics are relevant on Feb 12, 2024. For real-time TPS check out &lt;a href="https://chainspect.app/dashboard" rel="noopener noreferrer"&gt;our dashboard&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://chainspect.app/chain/algorand" rel="noopener noreferrer"&gt;Algorand&lt;/a&gt; TPS is 18.02 transactions per second&lt;br&gt;
&lt;a href="https://chainspect.app/chain/algorand" rel="noopener noreferrer"&gt;Algorand&lt;/a&gt; Max TPS is 3,227 transactions per second&lt;br&gt;&lt;br&gt;
&lt;a href="https://chainspect.app/chain/arbitrum" rel="noopener noreferrer"&gt;Arbitrum&lt;/a&gt; TPS is 10.6 transactions per second&lt;br&gt;
&lt;a href="https://chainspect.app/chain/arbitrum" rel="noopener noreferrer"&gt;Arbitrum&lt;/a&gt; Max TPS is 380 transactions per second&lt;br&gt;&lt;br&gt;
&lt;a href="https://chainspect.app/chain/avalanche" rel="noopener noreferrer"&gt;Avalanche&lt;/a&gt; TPS is 2.41 transactions per second&lt;br&gt;
&lt;a href="https://chainspect.app/chain/avalanche" rel="noopener noreferrer"&gt;Avalanche&lt;/a&gt; Max TPS is 92.74 transactions per second&lt;br&gt;&lt;br&gt;
&lt;a href="https://chainspect.app/chain/base" rel="noopener noreferrer"&gt;Base&lt;/a&gt; TPS is 5.41 transactions per second&lt;br&gt;
&lt;a href="https://chainspect.app/chain/base" rel="noopener noreferrer"&gt;Base&lt;/a&gt; Max TPS is 34.52 transactions per second&lt;br&gt;&lt;br&gt;
&lt;a href="https://chainspect.app/chain/bitcoin" rel="noopener noreferrer"&gt;Bitcoin&lt;/a&gt; TPS is 8.59 transactions per second&lt;br&gt;
&lt;a href="https://chainspect.app/chain/bitcoin" rel="noopener noreferrer"&gt;Bitcoin&lt;/a&gt; Max TPS is 10.92 transactions per second&lt;br&gt;&lt;br&gt;
&lt;a href="https://chainspect.app/chain/bnb-chain" rel="noopener noreferrer"&gt;BNB Chain&lt;/a&gt; TPS is 42.42 transactions per second&lt;br&gt;
&lt;a href="https://chainspect.app/chain/bnb-chain" rel="noopener noreferrer"&gt;BNB Chain&lt;/a&gt; Max TPS is 1,731 transactions per second&lt;br&gt;&lt;br&gt;
&lt;a href="https://chainspect.app/chain/bnb-greenfield" rel="noopener noreferrer"&gt;BNB Greenfield&lt;/a&gt; TPS is 0.13 transactions per scond&lt;br&gt;
&lt;a href="https://chainspect.app/chain/bnb-greenfield" rel="noopener noreferrer"&gt;BNB Greenfield&lt;/a&gt; Max TPS is 2.25 transactions per second&lt;br&gt;&lt;br&gt;
&lt;a href="https://chainspect.app/chain/celo" rel="noopener noreferrer"&gt;Celo&lt;/a&gt; TPS is 4.39 transactions per second&lt;br&gt;
&lt;a href="https://chainspect.app/chain/celo" rel="noopener noreferrer"&gt;Celo&lt;/a&gt; Max TPS is 268 transactions per second&lt;br&gt;&lt;br&gt;
&lt;a href="https://chainspect.app/chain/cronos" rel="noopener noreferrer"&gt;Cronos&lt;/a&gt; TPS is 0.31 transactions per second&lt;br&gt;
&lt;a href="https://chainspect.app/chain/cronos" rel="noopener noreferrer"&gt;Cronos&lt;/a&gt; Max TPS is 142 transactions per second&lt;br&gt;&lt;br&gt;
&lt;a href="https://chainspect.app/chain/crust" rel="noopener noreferrer"&gt;Crust&lt;/a&gt; TPS is 0 transactions per second&lt;br&gt;
&lt;a href="https://chainspect.app/chain/crust" rel="noopener noreferrer"&gt;Crust&lt;/a&gt; Max TPS is 0.01 transactions per second&lt;br&gt;&lt;br&gt;
&lt;a href="https://chainspect.app/chain/ethereum" rel="noopener noreferrer"&gt;Ethereum&lt;/a&gt; TPS is 11.75 transactions per second&lt;br&gt;
&lt;a href="https://chainspect.app/chain/ethereum" rel="noopener noreferrer"&gt;Ethereum&lt;/a&gt; Max TPS is 62.34 transactions per second&lt;br&gt;&lt;br&gt;
&lt;a href="https://chainspect.app/chain/fantom" rel="noopener noreferrer"&gt;Fantom&lt;/a&gt; TPS is 3.2 transactions per second&lt;br&gt;
&lt;a href="https://chainspect.app/chain/fantom" rel="noopener noreferrer"&gt;Fantom&lt;/a&gt; Max TPS is 181 transactions per second&lt;br&gt;&lt;br&gt;
&lt;a href="https://chainspect.app/chain/gnosis" rel="noopener noreferrer"&gt;Gnosis Chain&lt;/a&gt; TPS is 2.36 transactions per second&lt;br&gt;
&lt;a href="https://chainspect.app/chain/gnosis" rel="noopener noreferrer"&gt;Gnosis Chain&lt;/a&gt; Max TPS is 80.9 transactions per second&lt;br&gt;&lt;br&gt;
&lt;a href="https://chainspect.app/chain/hedera" rel="noopener noreferrer"&gt;Hedera&lt;/a&gt; TPS is 1,332 transactions per second&lt;br&gt;
&lt;a href="https://chainspect.app/chain/hedera" rel="noopener noreferrer"&gt;Hedera&lt;/a&gt; Max TPS is 3,287 transactions per second&lt;br&gt;&lt;br&gt;
&lt;a href="https://chainspect.app/chain/integritee" rel="noopener noreferrer"&gt;Integritee&lt;/a&gt; TPS is 0.0006 transactions per second&lt;br&gt;
&lt;a href="https://chainspect.app/chain/integritee" rel="noopener noreferrer"&gt;Integritee&lt;/a&gt; Max TPS is 0.04 transactions per second&lt;br&gt;&lt;br&gt;
&lt;a href="https://chainspect.app/chain/iotex" rel="noopener noreferrer"&gt;IoTeX&lt;/a&gt; TPS is 0.13 transactions per second&lt;br&gt;
&lt;a href="https://chainspect.app/chain/iotex" rel="noopener noreferrer"&gt;IoTeX&lt;/a&gt; Max TPS is 223 transactions per second&lt;br&gt;&lt;br&gt;
&lt;a href="https://chainspect.app/chain/opbnb" rel="noopener noreferrer"&gt;opBNB&lt;/a&gt; TPS is 46.44 transactions per second&lt;br&gt;
&lt;a href="https://chainspect.app/chain/opbnb" rel="noopener noreferrer"&gt;opBNB&lt;/a&gt; Max TPS is 229 transactions per second&lt;br&gt;&lt;br&gt;
&lt;a href="https://chainspect.app/chain/optimism" rel="noopener noreferrer"&gt;Optimism&lt;/a&gt; TPS is 4.59 transactions per second&lt;br&gt;
&lt;a href="https://chainspect.app/chain/optimism" rel="noopener noreferrer"&gt;Optimism&lt;/a&gt; Max TPS is 32.87 transactions per second&lt;br&gt;&lt;br&gt;
&lt;a href="https://chainspect.app/chain/polkadex" rel="noopener noreferrer"&gt;Polkadex&lt;/a&gt; TPS is 0.0036 transactions per second&lt;br&gt;
&lt;a href="https://chainspect.app/chain/polkadex" rel="noopener noreferrer"&gt;Polkadex&lt;/a&gt; Max TPS is 0.45 transactions per second&lt;br&gt;&lt;br&gt;
&lt;a href="https://chainspect.app/chain/polkadot" rel="noopener noreferrer"&gt;Polkadot&lt;/a&gt; TPS is 0.15 transactions per second&lt;br&gt;
&lt;a href="https://chainspect.app/chain/polkadot" rel="noopener noreferrer"&gt;Polkadot&lt;/a&gt; Max TPS is 112 transactions per second&lt;br&gt;&lt;br&gt;
&lt;a href="https://chainspect.app/chain/polygon" rel="noopener noreferrer"&gt;Polygon&lt;/a&gt; TPS is 44.33 transactions per second&lt;br&gt;
&lt;a href="https://chainspect.app/chain/polygon" rel="noopener noreferrer"&gt;Polygon&lt;/a&gt; Max TPS is 282 transactions per second&lt;br&gt;&lt;br&gt;
&lt;a href="https://chainspect.app/chain/scroll" rel="noopener noreferrer"&gt;Scroll&lt;/a&gt; TPS is 3.01 transactions per second&lt;br&gt;
&lt;a href="https://chainspect.app/chain/scroll" rel="noopener noreferrer"&gt;Scroll&lt;/a&gt; Max TPS is 25.86 transactions per second&lt;br&gt;&lt;br&gt;
&lt;a href="https://chainspect.app/chain/sirius" rel="noopener noreferrer"&gt;Sirius&lt;/a&gt; TPS is 0.01 transactions per second&lt;br&gt;
&lt;a href="https://chainspect.app/chain/sirius" rel="noopener noreferrer"&gt;Sirius&lt;/a&gt; Max TPS is 0.02 transactions per second&lt;br&gt;&lt;br&gt;
&lt;a href="https://chainspect.app/chain/solana" rel="noopener noreferrer"&gt;Solana&lt;/a&gt; TPS is 896 transactions per second&lt;br&gt;
&lt;a href="https://chainspect.app/chain/solana" rel="noopener noreferrer"&gt;Solana&lt;/a&gt; Max TPS is 1,608 transactions per second&lt;br&gt;&lt;br&gt;
&lt;a href="https://chainspect.app/chain/starknet" rel="noopener noreferrer"&gt;Starknet&lt;/a&gt; TPS is 1.89 transactions per second&lt;br&gt;
&lt;a href="https://chainspect.app/chain/starknet" rel="noopener noreferrer"&gt;Starknet&lt;/a&gt; Max TPS is 22.87 transactions per second&lt;br&gt;&lt;br&gt;
&lt;a href="https://chainspect.app/chain/telos" rel="noopener noreferrer"&gt;Telos&lt;/a&gt; TPS is 3.2 transactions per second&lt;br&gt;
&lt;a href="https://chainspect.app/chain/telos" rel="noopener noreferrer"&gt;Telos&lt;/a&gt; Max TPS is 7.5 transactions per second&lt;br&gt;&lt;br&gt;
&lt;a href="https://chainspect.app/chain/tron" rel="noopener noreferrer"&gt;Tron&lt;/a&gt; TPS is 56.52 transactions per second&lt;br&gt;
&lt;a href="https://chainspect.app/chain/tron" rel="noopener noreferrer"&gt;Tron&lt;/a&gt; Max TPS is 236 transactions per second&lt;br&gt;&lt;br&gt;
&lt;a href="https://chainspect.app/chain/zeitgeist" rel="noopener noreferrer"&gt;Zeitgeist&lt;/a&gt; TPS is 0.0011 transactions per second&lt;br&gt;
&lt;a href="https://chainspect.app/chain/zeitgeist" rel="noopener noreferrer"&gt;Zeitgeist&lt;/a&gt; Max TPS is 0.08 transactions per second  &lt;/p&gt;




&lt;p&gt;&lt;a href="https://chainspect.app/" rel="noopener noreferrer"&gt;Website&lt;/a&gt; | &lt;a href="https://twitter.com/chainspect_app" rel="noopener noreferrer"&gt;Twitter&lt;/a&gt; | &lt;a href="https://discord.com/invite/nnmJf56XYU" rel="noopener noreferrer"&gt;Discord&lt;/a&gt;&lt;/p&gt;

</description>
      <category>blockchain</category>
      <category>performance</category>
      <category>bitcoin</category>
      <category>ethereum</category>
    </item>
    <item>
      <title>TPScore: transactions per second metrics made easy</title>
      <dc:creator>Nick</dc:creator>
      <pubDate>Tue, 26 Sep 2023 10:56:55 +0000</pubDate>
      <link>https://forem.com/fromaline/tpscore-transactions-per-second-metrics-made-easy-508f</link>
      <guid>https://forem.com/fromaline/tpscore-transactions-per-second-metrics-made-easy-508f</guid>
      <description>&lt;h2&gt;
  
  
  Basic idea
&lt;/h2&gt;

&lt;p&gt;TPScore simplifies TPS Data Analysis for non-technical users in the Polkadot Ecosystem.&lt;/p&gt;

&lt;p&gt;TPScore aims to provide non-technical users in the Polkadot ecosystem with an accessible and user-friendly platform for analyzing TPS (Transactions per Second) data. Our goal is to bridge the gap between technical intricacies and user-friendly visualization, empowering individuals to make informed decisions about blockchain adoption, investment, and development.&lt;/p&gt;

&lt;h2&gt;
  
  
  How it was build
&lt;/h2&gt;

&lt;p&gt;The project was build for the &lt;a href="https://grants.web3.foundation/"&gt;Web3 Foundation Grants Program&lt;/a&gt;. TPScore consists of two main parts:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://github.com/BCS-Labs/tpscore-etl-system"&gt;ETL System&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/BCS-Labs/tpscore-web-client"&gt;User Interface (UI) with Data Visualizations&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  ETL System
&lt;/h3&gt;

&lt;p&gt;We retrieve blockchain data using either the &lt;a href="https://support.subscan.io/#introduction"&gt;Subscan API&lt;/a&gt; or connect to the public endpoints of parachains using the &lt;a href="https://pypi.org/project/substrate-interface/1.0.3/"&gt;Substrate interface library&lt;/a&gt;. Also we use Apache Airflow to ensure streamlined data processing.&lt;/p&gt;

&lt;p&gt;To calculate the average TPS, we take the number of transactions within the last 100 blocks. We fetch raw data at regular intervals of every 10 minutes. This raw data then undergoes processing within Airflow's DAGs using Python Operators, ensuring efficient data transformation and preparation. Finally, the processed data is stored in a MySQL database.&lt;/p&gt;

&lt;h3&gt;
  
  
  User Interface
&lt;/h3&gt;

&lt;p&gt;We use &lt;a href="https://nextjs.org/"&gt;Next.js&lt;/a&gt; as our full-stack framework. It allows to both retrieve data from the MySQL database and render React app on a server. &lt;/p&gt;

&lt;p&gt;To visualize data, we use a simple and concise UI: the grid of cards with the blockchain's name and TPS. We expect one common use case: users go to our website and scan through all chains to find a desired one. So we simplify this process by adding handy sorting and searching functionality.&lt;/p&gt;

&lt;h2&gt;
  
  
  How to use it
&lt;/h2&gt;

&lt;p&gt;Go to &lt;a href="https://tpscore.xyz/"&gt;tpscore.xyz&lt;/a&gt; and grasp real-time transactions per second metrics for the desired blockchain in Polkadot ecosystem.&lt;/p&gt;

&lt;h2&gt;
  
  
  How to contribute
&lt;/h2&gt;

&lt;p&gt;We provide detailed guide for both &lt;a href="https://github.com/BCS-Labs/tpscore-etl-system#readme"&gt;ETL System&lt;/a&gt; and &lt;a href="https://github.com/BCS-Labs/tpscore-web-client#readme"&gt;User Interface&lt;/a&gt;. You can easily spin up local development setup with Docker by following simple steps from READMEs. Also we provide inline documentation for you. Core logic is fully covered by unit tests, so you can contribute without fear of breaking anything.&lt;/p&gt;

</description>
      <category>blockchain</category>
      <category>polkadot</category>
      <category>opensource</category>
      <category>web3</category>
    </item>
    <item>
      <title>Examining Blockchain Transaction Speed: Real Performance vs. Marketing Claims</title>
      <dc:creator>Nick</dc:creator>
      <pubDate>Wed, 13 Sep 2023 09:09:38 +0000</pubDate>
      <link>https://forem.com/fromaline/examining-blockchain-transaction-speed-real-performance-vs-marketing-claims-417g</link>
      <guid>https://forem.com/fromaline/examining-blockchain-transaction-speed-real-performance-vs-marketing-claims-417g</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;In the ever-changing world of blockchain technology, there's often a lot of talk about how many transactions it can handle per second. But let's take a closer look beyond the marketing hype and dive into the actual world of blockchain speed, without all the complicated terms and fancy talk.&lt;/p&gt;

&lt;h2&gt;
  
  
  Understanding Blockchain Speed
&lt;/h2&gt;

&lt;p&gt;In the world of blockchain, you often see big flashy numbers like "maximum transactions per second" advertised on websites and in marketing materials. But as people who use blockchain tech, we can tell fact from fiction. Today we will explore the real-time transaction speed versus those big "maximum transactions per second" claims that might change how you see things.&lt;/p&gt;

&lt;h2&gt;
  
  
  Setting the Stage: Real-Time vs. Maximum Theoretical Throughput
&lt;/h2&gt;

&lt;p&gt;We expect there to be a difference between how many transactions a blockchain can handle in real-time and what's often advertised as the maximum throughput. Our goal is to dig deep and provide a detailed understanding that goes beyond surface-level numbers.&lt;/p&gt;

&lt;h2&gt;
  
  
  Our Approach: Revealing Actual Network Activity
&lt;/h2&gt;

&lt;p&gt;Our method involves connecting to blockchain networks, fetching transactions, and calculating the average TPS based on data from the last 100 blocks. Every blockchain has its own pace with varying block times, but we're not going to take block time into consideration today for simplicity purposes.&lt;/p&gt;

&lt;h2&gt;
  
  
  Examining Well-Known Blockchain Projects
&lt;/h2&gt;

&lt;p&gt;Let's take a good look at some well-known blockchain networks – Solana, Arbitrum, Avalanche, Ethereum, and Bitcoin – and see how they really perform.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F66o2zpzwsocwr0dja1ue.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F66o2zpzwsocwr0dja1ue.png" alt="Solana"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Solana might have said they can do "65,000 transactions per second" on their website, but in reality, they're clocking in at a pretty impressive 299.91! That's a huge 217 times more than what they claimed.&lt;/p&gt;



&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmf27z4b0gy7h1wjcdyn9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmf27z4b0gy7h1wjcdyn9.png" alt="Arbitrum"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Arbitrum advertised a solid "40,000 transactions per second," but our investigation shows that they're really doing just 8.07 transactions per second. That's a massive difference of 4956 times – a real wake-up call for accurate reporting.&lt;/p&gt;



&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqld9uuxxfwgkcsn7v8p2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqld9uuxxfwgkcsn7v8p2.png" alt="Avalanche"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Avalanche claimed "4,500 transactions per second," but the actual speed is much lower at 2.01 transactions per second. This significant difference of 2500 times shows the importance of being transparent about real-world performance.&lt;/p&gt;



&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwi5wplx6vwcibxti2dar.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwi5wplx6vwcibxti2dar.png" alt="Ethereum"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Ethereum hasn't been making big claims about speed. Their maximum recorded speed is 56, and their current speed is around 11.14 transactions per second. While it's just five times less, it shows they're not overhyping their capabilities.&lt;/p&gt;



&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmc4qdvoky4h9pwv2rgum.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmc4qdvoky4h9pwv2rgum.png" alt="Bitcoin"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Bitcoin has never tried to be the fastest. Theoretically, it can handle about 7 transactions per second, but in practice, it's around 4.18. It's just 1.67 times less, but Bitcoin is all about trustworthiness and resilience.&lt;/p&gt;

&lt;h2&gt;
  
  
  Closing Thoughts: More Than Just Numbers
&lt;/h2&gt;

&lt;p&gt;These findings highlight the big difference between what blockchain projects say they can do and what they actually do in the real world. While big numbers can be impressive, they're not the only measure of success. What really matters is how these technologies are adopted and used.&lt;/p&gt;

&lt;h2&gt;
  
  
  Data Source and Verification
&lt;/h2&gt;

&lt;p&gt;We got our data from &lt;a href="https://chainspect.app/" rel="noopener noreferrer"&gt;chainspect.app&lt;/a&gt; 🚀, but we encourage you to double-check our analysis. Blockchain's strength lies in its transparency and being able to verify things for yourself. Explore, scrutinize, and let the truth speak for itself.&lt;/p&gt;

</description>
      <category>blockchain</category>
      <category>performance</category>
      <category>ethereum</category>
      <category>bitcoin</category>
    </item>
    <item>
      <title>10 Must-Have Tools for Every Developer in 2023</title>
      <dc:creator>Nick</dc:creator>
      <pubDate>Mon, 27 Mar 2023 10:02:27 +0000</pubDate>
      <link>https://forem.com/fromaline/10-must-have-tools-for-every-developer-in-2023-6c5</link>
      <guid>https://forem.com/fromaline/10-must-have-tools-for-every-developer-in-2023-6c5</guid>
      <description>&lt;p&gt;As the technology landscape continues to evolve, so do the tools that developers rely on to create software. With the start of the new year, it's time to take a look at the top 10 must-have tools for developers in 2023.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;GitHub Copilot: This AI-powered coding assistant is a game-changer for developers. It uses machine learning to suggest code snippets and autocomplete code, making coding faster and more efficient.&lt;/li&gt;
&lt;li&gt;Docker: Docker containers allow developers to create and deploy applications quickly and reliably. It's a must-have tool for those who want to streamline their development workflow.&lt;/li&gt;
&lt;li&gt;VS Code: This lightweight, open-source code editor has become the go-to tool for many developers. It offers a wide range of features, including debugging, syntax highlighting, and Git integration.&lt;/li&gt;
&lt;li&gt;CircleCI: This cloud-based platform automates the testing and deployment process, making it easier for developers to deliver high-quality code faster.&lt;/li&gt;
&lt;li&gt;Postman: This API development tool simplifies the process of testing and debugging APIs. It's a must-have for developers who work with APIs regularly.&lt;/li&gt;
&lt;li&gt;React Native: This JavaScript framework allows developers to build native mobile apps for iOS and Android using a single codebase. It's a great tool for those who want to develop mobile apps quickly.&lt;/li&gt;
&lt;li&gt;Elasticsearch: This distributed search and analytics engine is a must-have for developers who work with large amounts of data. It offers fast search and indexing capabilities, making it easy to find and analyze data.&lt;/li&gt;
&lt;li&gt;Sentry: This error tracking tool helps developers quickly identify and fix bugs in their code. It integrates with many popular frameworks and languages, including JavaScript, Python, and Ruby.&lt;/li&gt;
&lt;li&gt;GitLab: This web-based Git repository management tool offers a wide range of features, including continuous integration and deployment, code review, and issue tracking.&lt;/li&gt;
&lt;li&gt;Terraform: This infrastructure-as-code tool allows developers to manage their infrastructure as code. It simplifies the process of managing and scaling infrastructure, making it easier to deploy applications to the cloud.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;In conclusion, these are the 10 must-have tools for every developer in 2023. Whether you're a beginner or an experienced developer, these tools will help you streamline your workflow, increase your productivity, and deliver high-quality code faster. So, what are you waiting for? Start exploring these tools today and take your development skills to the next level! [Generated by ChatGPT]&lt;/p&gt;

</description>
      <category>ai</category>
      <category>chatgpt</category>
      <category>webdev</category>
      <category>tooling</category>
    </item>
    <item>
      <title>My dream habit tracker</title>
      <dc:creator>Nick</dc:creator>
      <pubDate>Thu, 02 Mar 2023 21:40:40 +0000</pubDate>
      <link>https://forem.com/fromaline/my-dream-habit-tracker-10g8</link>
      <guid>https://forem.com/fromaline/my-dream-habit-tracker-10g8</guid>
      <description>&lt;p&gt;After almost a year of having no side activity whatsoever, it seems like I’m finally getting back on track!&lt;/p&gt;

&lt;p&gt;I've built my dream habit tracker with Vue 3 &amp;amp; PocketBase!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--PS6wMSSP--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/odw758gtl5z1pnpbtjd5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--PS6wMSSP--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/odw758gtl5z1pnpbtjd5.png" alt="habitable main screen" width="800" height="1159"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you have any pain points with your current habit tracker, let me know in the comments, because I have a lot of them with tons of habit trackers I've tried throughout my life!&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>vue</category>
      <category>pocketbase</category>
      <category>webdev</category>
    </item>
    <item>
      <title>What's the difference between compiler, transpiler, and interpreter?</title>
      <dc:creator>Nick</dc:creator>
      <pubDate>Fri, 25 Feb 2022 17:54:22 +0000</pubDate>
      <link>https://forem.com/fromaline/whats-the-difference-between-compiler-transpiler-and-interpreter-4nif</link>
      <guid>https://forem.com/fromaline/whats-the-difference-between-compiler-transpiler-and-interpreter-4nif</guid>
      <description>&lt;p&gt;Implementations of different programming languages use various techniques to execute the code. Let's figure out the difference between them.&lt;/p&gt;

&lt;h2&gt;
  
  
  Compilers
&lt;/h2&gt;

&lt;p&gt;A compiler is a program that translates a high-level language to bytecode or machine code. &lt;br&gt;
At the same time, a compiler itself doesn't execute the resulting code. The user has to do it instead.&lt;/p&gt;

&lt;p&gt;Examples of compilers: GCC, javac, rustc&lt;/p&gt;
&lt;h2&gt;
  
  
  Transpilers
&lt;/h2&gt;

&lt;p&gt;A transpiler is similar to a compiler, but it translates source code to another high-level language instead of bytecode/machine code. &lt;br&gt;
A transpiler doesn't execute the resulting code too.&lt;/p&gt;

&lt;p&gt;Examples of transpilers: babel, tsc&lt;/p&gt;
&lt;h2&gt;
  
  
  Interpreters
&lt;/h2&gt;

&lt;p&gt;An interpreter, in turn, takes in the source code and executes it immediately. In other words, it runs it from the source.&lt;/p&gt;

&lt;p&gt;Examples of interpreters: Ruby MRI (CRuby), PHP3&lt;/p&gt;
&lt;h2&gt;
  
  
  The combination
&lt;/h2&gt;

&lt;p&gt;There are a lot of programming languages implementations that use compiling and interpreting techniques together. &lt;a href="http://www.craftinginterpreters.com/image/a-map-of-the-territory/venn.png" rel="noopener noreferrer"&gt;Robert Nystrom captured such implementations for his "Crafting Interpreters" book.&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/http%3A%2F%2Fwww.craftinginterpreters.com%2Fimage%2Fa-map-of-the-territory%2Fvenn.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/http%3A%2F%2Fwww.craftinginterpreters.com%2Fimage%2Fa-map-of-the-territory%2Fvenn.png" alt="chart with compilers and interpreters"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This combination allows getting the best from both worlds. &lt;br&gt;
The execution will be faster because it's generally easier to optimize bytecode. At the same time, it's more convenient for the user to run source code with a single command. &lt;/p&gt;

&lt;p&gt;For example, CPython works like this.&lt;/p&gt;



&lt;p&gt;P.S. &lt;a href="https://twitter.com/fromaline" rel="noopener noreferrer"&gt;Follow me on Twitter&lt;/a&gt; for more content like this.&lt;/p&gt;

&lt;p&gt;&lt;iframe class="tweet-embed" id="tweet-1496152664039735309-972" src="https://platform.twitter.com/embed/Tweet.html?id=1496152664039735309"&gt;
&lt;/iframe&gt;

  // Detect dark theme
  var iframe = document.getElementById('tweet-1496152664039735309-972');
  if (document.body.className.includes('dark-theme')) {
    iframe.src = "https://platform.twitter.com/embed/Tweet.html?id=1496152664039735309&amp;amp;theme=dark"
  }



&lt;/p&gt;

</description>
      <category>programming</category>
      <category>computerscience</category>
    </item>
    <item>
      <title>JSX.Element vs ReactElement vs ReactNode</title>
      <dc:creator>Nick</dc:creator>
      <pubDate>Mon, 14 Feb 2022 19:34:32 +0000</pubDate>
      <link>https://forem.com/fromaline/jsxelement-vs-reactelement-vs-reactnode-2mh2</link>
      <guid>https://forem.com/fromaline/jsxelement-vs-reactelement-vs-reactnode-2mh2</guid>
      <description>&lt;p&gt;These three types usually confuse novice React developers. It seems like they are the same thing, just named differently.&lt;br&gt;
But it's not quite right.&lt;/p&gt;
&lt;h2&gt;
  
  
  &lt;code&gt;JSX.Element&lt;/code&gt; vs &lt;code&gt;ReactElement&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;Both types are the result of &lt;code&gt;React.createElement()&lt;/code&gt;/&lt;code&gt;jsx()&lt;/code&gt; function call.&lt;/p&gt;

&lt;p&gt;They are both objects with: &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;type&lt;/li&gt;
&lt;li&gt;props&lt;/li&gt;
&lt;li&gt;key&lt;/li&gt;
&lt;li&gt;a couple of other "hidden" properties, like ref, $$typeof, etc&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;
  
  
  &lt;code&gt;ReactElement&lt;/code&gt;
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;ReactElement&lt;/code&gt; type is the most basic of all. It's even defined &lt;a href="https://github.com/facebook/react/blob/v17.0.0/packages/shared/ReactElementType.js#L15"&gt;in React source code&lt;/a&gt; using flow!&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// ./packages/shared/ReactElementType.js&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="nx"&gt;type&lt;/span&gt; &lt;span class="nx"&gt;ReactElement&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="o"&gt;|&lt;/span&gt;
  &lt;span class="nx"&gt;$&lt;/span&gt;&lt;span class="na"&gt;$typeof&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;any&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;any&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;key&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;any&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;ref&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;any&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;props&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;any&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="c1"&gt;// ReactFiber&lt;/span&gt;
  &lt;span class="na"&gt;_owner&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;any&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;

  &lt;span class="c1"&gt;// __DEV__&lt;/span&gt;
  &lt;span class="na"&gt;_store&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="na"&gt;validated&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;boolean&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;...},&lt;/span&gt;
  &lt;span class="na"&gt;_self&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;React$Element&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;any&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;_shadowChildren&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;any&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;_source&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;Source&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="o"&gt;|&lt;/span&gt;&lt;span class="p"&gt;};&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This type is also defined &lt;a href="https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/react/index.d.ts#L146"&gt;in DefinitelyTyped package&lt;/a&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kr"&gt;interface&lt;/span&gt; &lt;span class="nx"&gt;ReactElement&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;P&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kr"&gt;any&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;T&lt;/span&gt; &lt;span class="kd"&gt;extends&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="nx"&gt;JSXElementConstructor&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="kr"&gt;any&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="nx"&gt;JSXElementConstructor&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="kr"&gt;any&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;T&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;props&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;P&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;key&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;Key&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  &lt;code&gt;JSX.Element&lt;/code&gt;
&lt;/h3&gt;

&lt;p&gt;It's more generic type. &lt;a href="https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/react/index.d.ts#L3078"&gt;The key difference is that &lt;code&gt;props&lt;/code&gt; and &lt;code&gt;type&lt;/code&gt; are typed as &lt;code&gt;any&lt;/code&gt; in &lt;code&gt;JSX.Element&lt;/code&gt;&lt;/a&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kr"&gt;declare&lt;/span&gt; &lt;span class="nb"&gt;global&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;namespace&lt;/span&gt; &lt;span class="nx"&gt;JSX&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kr"&gt;interface&lt;/span&gt; &lt;span class="nx"&gt;Element&lt;/span&gt; &lt;span class="kd"&gt;extends&lt;/span&gt; &lt;span class="nx"&gt;React&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;ReactElement&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="kr"&gt;any&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kr"&gt;any&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="c1"&gt;// ...&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;   
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This gives flexibility in how different libraries implement JSX.&lt;br&gt;
For example, &lt;a href="https://github.com/preactjs/preact/blob/master/src/jsx.d.ts#L18"&gt;Preact has its own implementation with different API&lt;/a&gt;.&lt;/p&gt;
&lt;h2&gt;
  
  
  &lt;code&gt;ReactNode&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;ReactNode&lt;/code&gt; type is a different thing. It's not a return value of &lt;code&gt;React.createElement()&lt;/code&gt;/&lt;code&gt;jsx()&lt;/code&gt; function call.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;Component&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="c1"&gt;// Here it's ReactElement&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;Hello world!&lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c1"&gt;// Here it's ReactNode&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;Example&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Component&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;React node itself is a representation of the virtual DOM. So &lt;code&gt;ReactNode&lt;/code&gt; is the set of all possible return values of a component.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;type&lt;/span&gt; &lt;span class="nx"&gt;ReactChild&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;ReactElement&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="nx"&gt;ReactText&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;type&lt;/span&gt; &lt;span class="nx"&gt;ReactFragment&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{}&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="nx"&gt;Iterable&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;ReactNode&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kr"&gt;interface&lt;/span&gt; &lt;span class="nx"&gt;ReactPortal&lt;/span&gt; &lt;span class="kd"&gt;extends&lt;/span&gt; &lt;span class="nx"&gt;ReactElement&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;key&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;Key&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;children&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;ReactNode&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;type&lt;/span&gt; &lt;span class="nx"&gt;ReactNode&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt;
  &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="nx"&gt;ReactChild&lt;/span&gt;
  &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="nx"&gt;ReactFragment&lt;/span&gt;
  &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="nx"&gt;ReactPortal&lt;/span&gt;
  &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="nx"&gt;boolean&lt;/span&gt;
  &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;
  &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="kc"&gt;undefined&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  What to use for &lt;code&gt;children&lt;/code&gt;?
&lt;/h2&gt;

&lt;p&gt;Generally speaking, &lt;code&gt;ReactNode&lt;/code&gt; is the correct way to type the &lt;code&gt;children&lt;/code&gt; prop. It gives the most flexibility while maintaining the proper type checking.&lt;/p&gt;

&lt;p&gt;But it has a caveat, because &lt;code&gt;ReactFragment&lt;/code&gt; allows a &lt;code&gt;{}&lt;/code&gt; type.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight tsx"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;Item&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="nx"&gt;children&lt;/span&gt; &lt;span class="p"&gt;}:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nl"&gt;children&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;ReactNode&lt;/span&gt; &lt;span class="p"&gt;})&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;li&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;children&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;li&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;App&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;ul&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
      // Run-time error here, objects are not valid children!
      &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;Item&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="p"&gt;{}&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nc"&gt;Item&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;ul&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;p&gt;P.S. &lt;a href="https://twitter.com/fromaline"&gt;Follow me on Twitter&lt;/a&gt; for more content like this!&lt;/p&gt;

&lt;p&gt;&lt;iframe class="tweet-embed" id="tweet-1490749477346553861-711" src="https://platform.twitter.com/embed/Tweet.html?id=1490749477346553861"&gt;
&lt;/iframe&gt;

  // Detect dark theme
  var iframe = document.getElementById('tweet-1490749477346553861-711');
  if (document.body.className.includes('dark-theme')) {
    iframe.src = "https://platform.twitter.com/embed/Tweet.html?id=1490749477346553861&amp;amp;theme=dark"
  }



&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>react</category>
      <category>webdev</category>
      <category>beginners</category>
    </item>
    <item>
      <title>How do React Fragments work under the hood?</title>
      <dc:creator>Nick</dc:creator>
      <pubDate>Sun, 13 Feb 2022 09:33:09 +0000</pubDate>
      <link>https://forem.com/fromaline/how-do-react-fragments-work-under-the-hood-36n5</link>
      <guid>https://forem.com/fromaline/how-do-react-fragments-work-under-the-hood-36n5</guid>
      <description>&lt;p&gt;React aims to stay neat and clean that's why fragments are out there. They allow getting rid of excess wrappers while rendering multiple elements!&lt;/p&gt;

&lt;p&gt;That's pretty cool, but how do they work under the hood?&lt;/p&gt;

&lt;h2&gt;
  
  
  👉 React Fragment is just a React Element of a special type!
&lt;/h2&gt;

&lt;p&gt;JSX is a syntax sugar for calling &lt;code&gt;React.createElement&lt;/code&gt;&lt;br&gt;
This function expects only three possible groups of types:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;tag name for basic HTML elements&lt;/li&gt;
&lt;li&gt;class/function for user-defined components&lt;/li&gt;
&lt;li&gt;React fragment type
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// what you write&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;Items&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="o"&gt;&amp;lt;&amp;gt;&lt;/span&gt;
      &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;li&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;First&lt;/span&gt; &lt;span class="nx"&gt;element&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/li&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;      &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;li&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;Second&lt;/span&gt; &lt;span class="nx"&gt;element&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/li&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;      &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;li&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;Third&lt;/span&gt; &lt;span class="nx"&gt;element&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/li&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;  &lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c1"&gt;// what React gets after babel transpilation&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;Items&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;React&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;createElement&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="nx"&gt;React&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;Fragment&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; 
    &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nx"&gt;React&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;createElement&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;li&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;First element&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
    &lt;span class="nx"&gt;React&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;createElement&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;li&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Second element&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
    &lt;span class="nx"&gt;React&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;createElement&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;li&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Third element&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h2&gt;
  
  
  👉 How does React work with fragments?
&lt;/h2&gt;

&lt;p&gt;After all, there are no corresponding DOM elements!&lt;/p&gt;

&lt;p&gt;React doesn't need real DOM elements to deal with fragments.&lt;br&gt;
It forms a virtual DOM instead 💡&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Items() return this&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;type&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Symbol&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;react&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;fragment&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
  &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;key&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;ref&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;props&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;children&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
      &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;type&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;li&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;key&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;ref&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;props&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
          &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;children&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;First element&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
        &lt;span class="p"&gt;},&lt;/span&gt;
      &lt;span class="p"&gt;},&lt;/span&gt;
      &lt;span class="c1"&gt;// ...&lt;/span&gt;
    &lt;span class="p"&gt;]&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;ReactDOM&lt;/code&gt;, in turn, ignores fragments and renders all children without any wrappers. &lt;/p&gt;

&lt;h2&gt;
  
  
  👉 Verify that it works yourself!
&lt;/h2&gt;

&lt;p&gt;Go to &lt;a href="https://reactjs.org"&gt;reactjs.org&lt;/a&gt; and paste &lt;a href="https://github.com/fromaline/twitter-snippets/blob/master/snippets/25_Jan_2022/index.js"&gt;the &lt;code&gt;Items&lt;/code&gt; component&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;If DOM looks the same as here 👇, you've done a great job!&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;id=&lt;/span&gt;&lt;span class="s"&gt;"___gatsby"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;li&amp;gt;&lt;/span&gt;First element&lt;span class="nt"&gt;&amp;lt;/li&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;li&amp;gt;&lt;/span&gt;Second element&lt;span class="nt"&gt;&amp;lt;/li&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;li&amp;gt;&lt;/span&gt;Third element&lt;span class="nt"&gt;&amp;lt;/li&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;p&gt;P.S. &lt;a href="https://twitter.com/fromaline"&gt;Follow me on Twitter&lt;/a&gt; for more content like this!&lt;/p&gt;

&lt;p&gt;&lt;iframe class="tweet-embed" id="tweet-1492403718284886016-23" src="https://platform.twitter.com/embed/Tweet.html?id=1492403718284886016"&gt;
&lt;/iframe&gt;

  // Detect dark theme
  var iframe = document.getElementById('tweet-1492403718284886016-23');
  if (document.body.className.includes('dark-theme')) {
    iframe.src = "https://platform.twitter.com/embed/Tweet.html?id=1492403718284886016&amp;amp;theme=dark"
  }



&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>react</category>
      <category>webdev</category>
      <category>programming</category>
    </item>
    <item>
      <title>How does React allow creating custom components?</title>
      <dc:creator>Nick</dc:creator>
      <pubDate>Sun, 13 Feb 2022 08:41:10 +0000</pubDate>
      <link>https://forem.com/fromaline/how-does-react-allow-creating-custom-components-3mbe</link>
      <guid>https://forem.com/fromaline/how-does-react-allow-creating-custom-components-3mbe</guid>
      <description>&lt;p&gt;React strives to give its users the ability to build encapsulated, reusable components, but how does it implement this logic in JSX?&lt;/p&gt;

&lt;p&gt;Here is a simple example of a custom user-defined component, named &lt;code&gt;Greeting&lt;/code&gt;. It renders inside a well-known &lt;code&gt;App&lt;/code&gt; component.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Greeting.jsx&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;Greeting&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;({&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;})&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;span&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;Hi, &lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt; 👋&lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;span&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c1"&gt;// App.jsx&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;App&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;Greeting&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"Nikita"&lt;/span&gt; &lt;span class="p"&gt;/&amp;gt;&lt;/span&gt;
    &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Let's break it down!&lt;/p&gt;

&lt;h2&gt;
  
  
  👉 How &lt;code&gt;Greeting&lt;/code&gt; works?
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;Greeting&lt;/code&gt; is just a function, which returns JSX. JSX is syntax sugar for calling &lt;code&gt;React.createElement&lt;/code&gt; &lt;/li&gt;
&lt;li&gt;
&lt;code&gt;React.createElement&lt;/code&gt; expects three arguments:

&lt;ul&gt;
&lt;li&gt;type&lt;/li&gt;
&lt;li&gt;props&lt;/li&gt;
&lt;li&gt;children &lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Let's rewrite our &lt;code&gt;Greeting&lt;/code&gt; component with this new knowledge.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Greeting.jsx&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;Greeting&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;({&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;})&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;React&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;createElement&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;span&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; 
    &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; 
    &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Hi, &lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt; 👋&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  👉 How to use the &lt;code&gt;Greeting&lt;/code&gt; now?
&lt;/h2&gt;

&lt;p&gt;Turns out, &lt;code&gt;createElement&lt;/code&gt; expects three values as type: &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;tag name, like &lt;code&gt;div&lt;/code&gt; or &lt;code&gt;span&lt;/code&gt; &lt;/li&gt;
&lt;li&gt;a class or a function, that defines custom component &lt;/li&gt;
&lt;li&gt;React fragment type
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// App.jsx&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;App&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
 &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;React&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;createElement&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
   &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;div&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
   &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
   &lt;span class="nx"&gt;React&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;createElement&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;Greeting&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;})&lt;/span&gt;
 &lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Simply put, &lt;code&gt;createElement&lt;/code&gt; calls the passed function internally and uses its return value to form the component tree.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Internal intermediate result&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;App&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
 &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;React&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;createElement&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
   &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;div&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
   &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
   &lt;span class="nx"&gt;React&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;createElement&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
     &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;span&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; 
     &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; 
     &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Hi, &lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Nikita&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt; 👋&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;
   &lt;span class="p"&gt;)&lt;/span&gt;
 &lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  👉 Verify that it works yourself!
&lt;/h2&gt;

&lt;p&gt;Go to reactjs.org, open the console and paste &lt;a href="https://github.com/fromaline/twitter-snippets/blob/master/snippets/24_Jan_2022/index.js"&gt;the last code snippet&lt;/a&gt; there.&lt;/p&gt;

&lt;p&gt;Then call the &lt;code&gt;App()&lt;/code&gt; and see the end result. &lt;br&gt;
If it's the same as here 👇, you've done a great job!&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;type&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;div&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;key&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;ref&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;props&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;children&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;type&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;span&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;key&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;ref&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;props&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;children&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
          &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Hi, &lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
          &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Nikita&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
          &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt; 👋&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
        &lt;span class="p"&gt;]&lt;/span&gt;
      &lt;span class="p"&gt;},&lt;/span&gt;
      &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;_owner&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;},&lt;/span&gt;
  &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;_owner&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;p&gt;P.S. &lt;a href="https://twitter.com/fromaline"&gt;Follow me on Twitter&lt;/a&gt; for more content like this!&lt;/p&gt;

&lt;p&gt;&lt;iframe class="tweet-embed" id="tweet-1486750941814484995-29" src="https://platform.twitter.com/embed/Tweet.html?id=1486750941814484995"&gt;
&lt;/iframe&gt;

  // Detect dark theme
  var iframe = document.getElementById('tweet-1486750941814484995-29');
  if (document.body.className.includes('dark-theme')) {
    iframe.src = "https://platform.twitter.com/embed/Tweet.html?id=1486750941814484995&amp;amp;theme=dark"
  }



&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>react</category>
      <category>webdev</category>
      <category>programming</category>
    </item>
    <item>
      <title>How React components work?</title>
      <dc:creator>Nick</dc:creator>
      <pubDate>Wed, 09 Feb 2022 15:14:08 +0000</pubDate>
      <link>https://forem.com/fromaline/how-react-components-work-520f</link>
      <guid>https://forem.com/fromaline/how-react-components-work-520f</guid>
      <description>&lt;p&gt;&lt;em&gt;React Components&lt;/em&gt; are the fundamental building blocks of any React app. They allow us to simplify complex UIs by breaking them down into small chunks.&lt;/p&gt;

&lt;p&gt;But as always every abstraction has its cost and the very concept of &lt;em&gt;React Components&lt;/em&gt; confuses a lot of beginners, so let's figure it out!&lt;/p&gt;

&lt;h2&gt;
  
  
  React Component vs React Component instance vs React Element
&lt;/h2&gt;

&lt;p&gt;These three terms seemingly refer to a single thing - UI element on the screen. But it's not true.&lt;/p&gt;

&lt;h3&gt;
  
  
  React Component
&lt;/h3&gt;

&lt;p&gt;&lt;em&gt;React Component&lt;/em&gt; is either a function or an ES6 class - nothing more, nothing less. You manage the state, handle events and implement other custom logic here. &lt;br&gt;
It never renders anything to the screen. Instead, you create its instance to do that.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;TextButton&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;({&lt;/span&gt;&lt;span class="nx"&gt;text&lt;/span&gt;&lt;span class="p"&gt;})&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;button&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;text&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;button&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c1"&gt;// It becomes more obvious with class-based component&lt;/span&gt;
&lt;span class="c1"&gt;// because you extend React.Component, not React.Element&lt;/span&gt;
&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;ListItem&lt;/span&gt; &lt;span class="kd"&gt;extends&lt;/span&gt; &lt;span class="nc"&gt;React&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;Component&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nf"&gt;render&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;li&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;props&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;children&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;li&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  React Component Instance
&lt;/h3&gt;

&lt;p&gt;It's exactly what it sounds like. You may have an instance of the &lt;em&gt;React Component&lt;/em&gt; only at run time. &lt;br&gt;
Also, you may have multiple instances, each with its own properties and local state. It happens when you use &lt;em&gt;React Component&lt;/em&gt; more than once.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;ListItem&lt;/span&gt; &lt;span class="kd"&gt;extends&lt;/span&gt; &lt;span class="nc"&gt;React&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;Component&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nf"&gt;constructor&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;props&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;super&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;props&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;`This is instance &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="nf"&gt;render&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;li&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;props&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;children&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;li&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;App&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;ul&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;ListItem&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;First item&lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nc"&gt;ListItem&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;ListItem&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;Second item&lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nc"&gt;ListItem&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;ListItem&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;Third item&lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nc"&gt;ListItem&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;ul&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  React Element
&lt;/h3&gt;

&lt;p&gt;&lt;em&gt;React Element&lt;/em&gt; is what &lt;em&gt;React Component Instance&lt;/em&gt; returns at run-time. It's a plain JavaScript object that completely describes a DOM node.&lt;br&gt;
Multiple &lt;em&gt;React Elements&lt;/em&gt; together form a virtual DOM, a tree-like structure that describes the UI of your React app.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="c1"&gt;// After Babel&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;App&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;React&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;createElement&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;ul&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; 
    &lt;span class="nx"&gt;React&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;createElement&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;ListItem&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="na"&gt;children&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;First item&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;}),&lt;/span&gt;
    &lt;span class="nx"&gt;React&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;createElement&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;ListItem&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="na"&gt;children&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Second item&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;}),&lt;/span&gt;
    &lt;span class="nx"&gt;React&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;createElement&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;ListItem&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="na"&gt;children&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Third item&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;})&lt;/span&gt;
  &lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c1"&gt;// At run-time&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;App&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;type&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;ul&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; 
    &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;key&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; 
    &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;ref&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; 
    &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;props&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; 
      &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;children&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
        &lt;span class="p"&gt;{&lt;/span&gt; 
          &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;type&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;ListItem&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
          &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;key&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; 
          &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;ref&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; 
          &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;props&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; 
            &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;children&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;First item&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; 
          &lt;span class="p"&gt;},&lt;/span&gt;
        &lt;span class="p"&gt;},&lt;/span&gt;
        &lt;span class="c1"&gt;// ...&lt;/span&gt;
      &lt;span class="p"&gt;]&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  The big picture of how React Components work
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;React developers create either function-based or class-based &lt;em&gt;React Components&lt;/em&gt;, that return JSX.&lt;/li&gt;
&lt;li&gt;Babel transpiles JSX to &lt;code&gt;React.createElement()&lt;/code&gt; or &lt;a href="https://dev.to/fromaline/jsx-without-importing-react-28dj"&gt;&lt;code&gt;jsx()&lt;/code&gt;&lt;/a&gt; at build-time.&lt;/li&gt;
&lt;li&gt;React creates necessary &lt;em&gt;React Components Instances&lt;/em&gt; at run-time, and they return &lt;em&gt;React Elements&lt;/em&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;ReactDOM&lt;/code&gt; renders the virtual DOM, that consists of &lt;em&gt;React Elements&lt;/em&gt;.&lt;/li&gt;
&lt;/ol&gt;




&lt;p&gt;P.S. That's all for today! &lt;a href="https://twitter.com/fromaline"&gt;Follow me on Twitter&lt;/a&gt; for future content!&lt;/p&gt;

&lt;p&gt;&lt;iframe class="tweet-embed" id="tweet-1486411651175915527-493" src="https://platform.twitter.com/embed/Tweet.html?id=1486411651175915527"&gt;
&lt;/iframe&gt;

  // Detect dark theme
  var iframe = document.getElementById('tweet-1486411651175915527-493');
  if (document.body.className.includes('dark-theme')) {
    iframe.src = "https://platform.twitter.com/embed/Tweet.html?id=1486411651175915527&amp;amp;theme=dark"
  }



&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>webdev</category>
      <category>react</category>
      <category>programming</category>
    </item>
  </channel>
</rss>
