<?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>DEV Community: Yuxuan Zhang</title>
    <description>The latest articles on DEV Community by Yuxuan Zhang (@yuxuan_zhang_37c839da0f5a).</description>
    <link>https://dev.to/yuxuan_zhang_37c839da0f5a</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%2F2999802%2F5a2f094e-6457-4dd8-a4d1-191024d8a386.png</url>
      <title>DEV Community: Yuxuan Zhang</title>
      <link>https://dev.to/yuxuan_zhang_37c839da0f5a</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/yuxuan_zhang_37c839da0f5a"/>
    <language>en</language>
    <item>
      <title>React API design questions - from a beginner</title>
      <dc:creator>Yuxuan Zhang</dc:creator>
      <pubDate>Mon, 31 Mar 2025 23:29:37 +0000</pubDate>
      <link>https://dev.to/yuxuan_zhang_37c839da0f5a/react-api-design-questions-from-a-beginner-2f4l</link>
      <guid>https://dev.to/yuxuan_zhang_37c839da0f5a/react-api-design-questions-from-a-beginner-2f4l</guid>
      <description>&lt;p&gt;Hi,&lt;/p&gt;

&lt;p&gt;I do not have any experience on react/jsx, but I was involved in many other Node.js and frontend projects.&lt;/p&gt;

&lt;p&gt;When going through the &lt;em&gt;react.dev&lt;/em&gt; tutorials, I cannot help asking the following questions. &lt;strong&gt;I consulted ChatGPT before posting, but I was not satisfied by its answers.&lt;/strong&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Is it really necessary to rename attribute &lt;code&gt;class&lt;/code&gt; to &lt;code&gt;className&lt;/code&gt;?
&lt;/h3&gt;

&lt;p&gt;A common argument for that is &lt;code&gt;class&lt;/code&gt; being a reserved keyword in JS. However, it's perfectly fine to pass it as a dict key.&lt;/p&gt;

&lt;p&gt;Also, break-assignment can be renamed when catching &lt;code&gt;class&lt;/code&gt; attribute in function arguments:&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="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;Component&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;class&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;className&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;p&gt;Is there any other fundamental issue blocking the use of &lt;code&gt;class&lt;/code&gt; as an attribute? Could both &lt;code&gt;class&lt;/code&gt; and &lt;code&gt;className&lt;/code&gt; attributes be accepted in base DOM elements in a future version of react?&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Why mixing &lt;code&gt;children&lt;/code&gt; with other props?
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Instead of&lt;/span&gt;
&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;Component&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="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="p"&gt;...&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c1"&gt;// Why not&lt;/span&gt;
&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;Component&lt;/span&gt;&lt;span class="p"&gt;({&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="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="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;I just feel sad knowing that &lt;code&gt;children&lt;/code&gt; works different as other keys in the same level...&lt;/p&gt;




&lt;p&gt;I know there probably exist a ton of discussions on these topics, please feel free to shoot me links in case you know where to find them.&lt;/p&gt;

</description>
      <category>react</category>
    </item>
  </channel>
</rss>
