<?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: thuan1412</title>
    <description>The latest articles on DEV Community by thuan1412 (@thuan1412).</description>
    <link>https://dev.to/thuan1412</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%2F296762%2F4b6f2738-e5fe-4cdf-b35b-8bcc2c122d48.png</url>
      <title>DEV Community: thuan1412</title>
      <link>https://dev.to/thuan1412</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/thuan1412"/>
    <language>en</language>
    <item>
      <title>goent code base walkthrough</title>
      <dc:creator>thuan1412</dc:creator>
      <pubDate>Sat, 03 Sep 2022 07:43:21 +0000</pubDate>
      <link>https://dev.to/thuan1412/goent-code-walk-through-510k</link>
      <guid>https://dev.to/thuan1412/goent-code-walk-through-510k</guid>
      <description>&lt;p&gt;Hi everyone, I just found an awesome ORM in Go, that is &lt;a href="https://github.com/ent/ent"&gt;ent&lt;/a&gt; (go-ent). This library provides a code generation feature. With this feature, we-developers can have code suggestions about fields of the table, and easy to write a query to filter records based on condition, unlike other ORMs in Go like gorm, we have to write the raw condition of SQL query&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="n"&gt;db&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Where&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"name &amp;lt;&amp;gt; ?"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"Jinzhou"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Find&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="n"&gt;users&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this article, I will dive into the architecture of the ent framework, ...&lt;/p&gt;

&lt;p&gt;Ent's main packages&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;cmd: defines commands for the library.&lt;/li&gt;
&lt;li&gt;dialect: handles the dialect support for Mysql, PostgreSQL, SQLite, and Gremlin databases. The package also provides methods for the query builder. &lt;/li&gt;
&lt;li&gt;entql: provides (Unary, Binary, ... Expr) structs that implement &lt;code&gt;Stringer&lt;/code&gt; interface, these structs generate the expression from their properties. &lt;/li&gt;
&lt;li&gt;entc: provides an interface for interacting with entc (ent codegen) as a package rather than an executable&lt;/li&gt;
&lt;li&gt;privacy: provides a set of rules for user schema and deals with runtime evaluation.&lt;/li&gt;
&lt;li&gt;schema: contains structs that are used by developers when defining an ent schema.&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>go</category>
    </item>
    <item>
      <title>Callback function that use the state of useState() hook</title>
      <dc:creator>thuan1412</dc:creator>
      <pubDate>Sun, 21 Feb 2021 10:41:04 +0000</pubDate>
      <link>https://dev.to/thuan1412/callback-function-that-use-state-4dcl</link>
      <guid>https://dev.to/thuan1412/callback-function-that-use-state-4dcl</guid>
      <description>&lt;h1&gt;
  
  
  Callback function that use state
&lt;/h1&gt;

&lt;p&gt;The callback funtion of &lt;code&gt;setInterval&lt;/code&gt;, &lt;code&gt;setTimeout&lt;/code&gt; and eventListener only get the initialized value of &lt;code&gt;useState&lt;/code&gt; in React.&lt;/p&gt;

&lt;p&gt;You can see the demo &lt;a href="https://codesandbox.io/s/react-hooks-counter-demo-forked-ylqiu?file=/src/index.js"&gt;here&lt;/a&gt;. The value is log by the callback of setInterval alway be zero.&lt;/p&gt;

&lt;p&gt;We can use &lt;code&gt;useRef&lt;/code&gt; to solve this problem. See more solution on &lt;a href="https://stackoverflow.com/questions/60540985/react-usestate-doesnt-update-in-window-events"&gt;this&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Interesting tutorial about React hooks: &lt;a href="https://github.com/ohansemmanuel/react-hooks-cheatsheet"&gt;https://github.com/ohansemmanuel/react-hooks-cheatsheet&lt;/a&gt;&lt;/p&gt;

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