<?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: satriaherman</title>
    <description>The latest articles on DEV Community by satriaherman (@_satria_herman).</description>
    <link>https://dev.to/_satria_herman</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%2F720581%2F8f5c9edc-1ec9-4ad7-a334-38e8fef9b5a6.jpeg</url>
      <title>DEV Community: satriaherman</title>
      <link>https://dev.to/_satria_herman</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/_satria_herman"/>
    <language>en</language>
    <item>
      <title>Never Put Sensitive Data in Your JWT Payload</title>
      <dc:creator>satriaherman</dc:creator>
      <pubDate>Fri, 14 Nov 2025 03:34:36 +0000</pubDate>
      <link>https://dev.to/_satria_herman/never-put-sensitive-data-in-your-jwt-payload-345i</link>
      <guid>https://dev.to/_satria_herman/never-put-sensitive-data-in-your-jwt-payload-345i</guid>
      <description>&lt;h2&gt;
  
  
  Overview
&lt;/h2&gt;

&lt;p&gt;Do you use JWT for your Authentication?. What the data do you store in the JWT payload?. some non-sensitive data like &lt;strong&gt;user_id&lt;/strong&gt; or sensitive data like &lt;strong&gt;password&lt;/strong&gt;?. If you storing sensitive data in your &lt;strong&gt;JWT Payload&lt;/strong&gt; you should stop it from now.&lt;/p&gt;

&lt;p&gt;In this article i will give you the reason why you shouldn't store sensitive data in your &lt;strong&gt;JWT payload&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  What is JSON Web Token?
&lt;/h2&gt;

&lt;p&gt;Json Web Token(JWT) is an open standard used for transmitting data between applications in JSON format. JWT is digitally signed in the backend app, so the data cannot be modified by other parties.&lt;/p&gt;

&lt;h2&gt;
  
  
  JWT Structure
&lt;/h2&gt;

&lt;p&gt;by default, JWT structure consists 3 part. &lt;strong&gt;Header&lt;/strong&gt;, &lt;strong&gt;Payload&lt;/strong&gt; dan &lt;strong&gt;Signature&lt;/strong&gt;. Every part is separated by dot symbols &lt;strong&gt;(.)&lt;/strong&gt;. So, it will looks like&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;header.payload.signature
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And Here's the example of JSON Web Token&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNzA4MzQ1MTIzLCJleHAiOjE3MDgzNTUxMjN9.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Header
&lt;/h3&gt;

&lt;p&gt;Header is containing information the &lt;strong&gt;type&lt;/strong&gt; of token and signing &lt;strong&gt;algorithm&lt;/strong&gt; which is encoded in base64. &lt;/p&gt;

&lt;p&gt;when you go to &lt;a href="https://www.base64decode.org/" rel="noopener noreferrer"&gt;base64-decode&lt;/a&gt; and decode this header&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;it will showing&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{"alg":"HS256","typ":"JWT"}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Payload
&lt;/h3&gt;

&lt;p&gt;Basically Payload is the data that you want to send or people call it &lt;strong&gt;claims&lt;/strong&gt;. &lt;strong&gt;claims&lt;/strong&gt; is divided into 2 type &lt;strong&gt;public claims&lt;/strong&gt; and &lt;strong&gt;private claims&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Registered Claims&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;registered claims is type of claims that already registered by &lt;a href="https://jwt.io" rel="noopener noreferrer"&gt;jwt.io&lt;/a&gt; which recognized as a global standard. the example of registered claims are:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;iss&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;sub&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;aud&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;exp&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;nbf&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;iat&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;jti&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;to see full registered claims, you can visit this &lt;a href="https://datatracker.ietf.org/doc/html/rfc7519#section-4.1" rel="noopener noreferrer"&gt;link&lt;/a&gt;  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Public Claims&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Public Claims is &lt;strong&gt;common claims&lt;/strong&gt; that created by developer. this claims is usually used by most &lt;strong&gt;developers&lt;/strong&gt;. Developers recommended to register  this claims to &lt;a href="https://www.iana.org/assignments/jwt/jwt.xhtml" rel="noopener noreferrer"&gt;IANA JWT registry&lt;/a&gt; to avoid the &lt;strong&gt;collision&lt;/strong&gt; between claims that has same meaning&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Private Claims&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Private Claims is custom claims which used by developer to share information between parties and already agree by each parties. This Claims usually used to share information that not included in &lt;strong&gt;registered claims&lt;/strong&gt; and &lt;strong&gt;public claims&lt;/strong&gt; &lt;/p&gt;

&lt;p&gt;Now, try to decode the &lt;strong&gt;payload&lt;/strong&gt; on &lt;a href="https://www.base64decode.org/" rel="noopener noreferrer"&gt;base64-decode&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNzA4MzQ1MTIzLCJleHAiOjE3MDgzNTUxMjN9
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And this is what you got&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{"sub":"1234567890","name":"John Doe","iat":1708345123,"exp":1708355123}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Looks, the data can be decoded &lt;strong&gt;easily!!!&lt;/strong&gt;. This is the reason why you you should not storing &lt;strong&gt;sensitive data&lt;/strong&gt; in your &lt;strong&gt;JWT Payload&lt;/strong&gt; &lt;/p&gt;

&lt;h3&gt;
  
  
  Signature
&lt;/h3&gt;

&lt;p&gt;Signature is used to &lt;strong&gt;Verify&lt;/strong&gt; if the data is coming from &lt;strong&gt;valid parties&lt;/strong&gt;. This is what makes JWT is &lt;strong&gt;secure&lt;/strong&gt;. let me explain&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Signature&lt;/strong&gt; is containing &lt;strong&gt;encoded header&lt;/strong&gt;, the &lt;strong&gt;encoded payload&lt;/strong&gt; and &lt;strong&gt;a secret&lt;/strong&gt;. they are signed using algorithm that defined in &lt;strong&gt;header&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;For example, we are using &lt;strong&gt;HMACSHA256&lt;/strong&gt; algorithm to sign the signature. The system will created the signature like this&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;HMACSHA256(
  base64UrlEncode(header) + "." +
  base64UrlEncode(payload),
  secret)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When we send jwt token to backend, the backend will &lt;strong&gt;verify&lt;/strong&gt; if the token has valid &lt;strong&gt;signature&lt;/strong&gt;. with this concept, the hacker cannot &lt;strong&gt;abuse&lt;/strong&gt; the system by modifying the payload. without &lt;strong&gt;secret key&lt;/strong&gt; the hacker cannot generate the valid signature&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Payload in &lt;strong&gt;JWT&lt;/strong&gt; can be decoded and accessible for public. so, be aware with the data that you sent in &lt;strong&gt;payload&lt;/strong&gt;. &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;Hacker cannot generate valid signature without secret key. Make sure your secret key is safe&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

</description>
      <category>webdev</category>
      <category>programming</category>
      <category>career</category>
      <category>node</category>
    </item>
    <item>
      <title>How Race Conditions Can Break Your System?</title>
      <dc:creator>satriaherman</dc:creator>
      <pubDate>Thu, 06 Nov 2025 04:47:02 +0000</pubDate>
      <link>https://dev.to/_satria_herman/how-race-condition-will-kill-your-system-ef5</link>
      <guid>https://dev.to/_satria_herman/how-race-condition-will-kill-your-system-ef5</guid>
      <description>&lt;h2&gt;
  
  
  Overview
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Singleton&lt;/strong&gt;, is a one of most popular design pattern. The main purpose is to saving memory by reuse and sharing one instance rather than create a new one. It sounds like a great concept, but it could be a "Boomerang" if we implement that concept in the wrong case.&lt;/p&gt;

&lt;p&gt;Helo, i am Satria. Currently i'm working on Tech Company as a &lt;strong&gt;Software Engineer&lt;/strong&gt;. In this article i will share about my experience in implementing Singleton Design Pattern in the wrong case. So, let's go.&lt;/p&gt;

&lt;h2&gt;
  
  
  Problem Started
&lt;/h2&gt;

&lt;p&gt;The Incident is started when i created an application to manage the budgeting system in our company. It is using PostgreSQL as a Database Management System. The application that i built is a part of &lt;strong&gt;Company's Super App&lt;/strong&gt;. &lt;/p&gt;

&lt;p&gt;When I looked at the code in the Super App, i notice that everytime when we need to query to database, we always use the same &lt;strong&gt;database connection&lt;/strong&gt; and &lt;strong&gt;database session&lt;/strong&gt; that declared as a &lt;strong&gt;global variable&lt;/strong&gt;. here's the sample code&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;embed engine = create_engine(url)
Session = sessionmaker(bind=engine)
db = Session() 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Everytime we need to querying to database, we always use &lt;strong&gt;db&lt;/strong&gt;  variable. For the first time, i thought&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;Hmm, This is good. we can reduce the memory usage&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Everything going well when i test and debug the application by myself. But  the problem occuring when i entering the UAT Process. A lot of issues coming from users in day 1,and 60% of issues is about &lt;strong&gt;Inconsistency Data&lt;/strong&gt;. on the next day the same issue is still coming. and Users put the comment like this&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;Why my proposal data is not found?, Why my proposal data is different than i created before, why the approval process is stuck?&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Resolving The Problem
&lt;/h2&gt;

&lt;p&gt;At First i thought that the problem is coming from relationship between the table. So, i double-checked on the &lt;strong&gt;model&lt;/strong&gt; and &lt;strong&gt;database&lt;/strong&gt; schema. But, i found no problem with that. i also check the &lt;strong&gt;query to database&lt;/strong&gt;, and still didn't find the problem, the query is fine.   &lt;/p&gt;

&lt;p&gt;I tried all flow of the application again, and still didn't find t the problem. I’m really stressed out by this issue, I spent 3 days just trying to find the problem. On day 3, i remember that my application is using same database session for all query. And when i check on entry point file, our app is using &lt;strong&gt;4 worker&lt;/strong&gt; and every worker can running up to &lt;strong&gt;50 threads&lt;/strong&gt;. That's caused the race condition because one database session is used by more than &lt;strong&gt;one Thread&lt;/strong&gt;. So, i tried to refactor my code and create new database session in every function.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;def create_proposal():
  db_session = Session()
  try{
   ....
  except:
   db_session.rollback()
  finally:
   db_session.close()
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After i refactoring the code like above, The related issue is gone. And my application is ready to serve on Production.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Singleton&lt;/strong&gt; is a good concept to reduce memory usage. but not all type of instances is good to use singleton. In this case, database connection is suitable to use Singleton, because the data &lt;strong&gt;doesn't change everytime it's used&lt;/strong&gt;. But implementing a Singleton for a database session is a bad practice, because a database session can change every time it is used.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.linkedin.com/in/satria-herman/" rel="noopener noreferrer"&gt;Linkedin&lt;/a&gt;&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>ai</category>
      <category>programming</category>
      <category>career</category>
    </item>
    <item>
      <title>Manipulasi DOM Di Reactjs</title>
      <dc:creator>satriaherman</dc:creator>
      <pubDate>Thu, 11 Nov 2021 07:49:49 +0000</pubDate>
      <link>https://dev.to/_satria_herman/manipulasi-dom-4914</link>
      <guid>https://dev.to/_satria_herman/manipulasi-dom-4914</guid>
      <description>&lt;p&gt;Halo semua, apa kabar nih?. Semoga kabarnya baik-baik saja. Kali ini gw akan membahas tentang "gimana caranya manipulasi DOM di Reactjs?".&lt;/p&gt;

&lt;h1&gt;
  
  
  Pendahuluan
&lt;/h1&gt;

&lt;p&gt;Sebelumnya gw mau kasih tau kalo React menggunakan Virtual DOM dalam memanipulasi element HTML nya. Nah sih virtual DOM itu?. Virtual DOM adalah sebuah copy dari DOM yang memiliki property yang sama seperti DOM aslinya. Singkatnya gini jika kita membuat sebuah component dengan nama "Button" di React, maka React akan merender Component Button tersebut kedalam element HTML dan juga membuat Copy dari Element Button itu. nah copy dari element Button ini lah yang disebut "Virtual DOM". Nah pasti ada yang nanya?.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"Bang kenapa harus buat copy element itu dulu?, kan udah ada element yang di render?&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Nah ini adalah cara react untuk meminimalisir interaksi antar DOM yang tidak perlu. Misal jika kita punya &lt;strong&gt;10 element list&lt;/strong&gt;. dan kita ingin mengupdate list yang &lt;strong&gt;ketiga&lt;/strong&gt; saja. Maka browser akan mengupdate &lt;strong&gt;semua list&lt;/strong&gt; yang ada. ini akan berdampak pada &lt;strong&gt;performa&lt;/strong&gt; website kita, karena kita mengupdate DOM yang sebenarnya tidak diperlukan. Untuk inilah &lt;strong&gt;Virtual DOM&lt;/strong&gt; hadir sebagai penyelesaian dari masalah ini. Dengan Virtual DOM kita akan &lt;strong&gt;meminimalisir&lt;/strong&gt; terjadinya interaksi antar DOM yang tidak perlu. Virtual DOM akan mengecek perubahan yang ada lalu melakukan update pada DOM yang &lt;strong&gt;berubah saja&lt;/strong&gt;. Sehingga component lain yang tidak dirubah tidak akan &lt;strong&gt;diupdate&lt;/strong&gt; dan &lt;strong&gt;dirender&lt;/strong&gt; ulang.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.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%2Fjn52i7a19arq7ssh9ii3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2Fjn52i7a19arq7ssh9ii3.png" alt=" " width="800" height="331"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;ilustrasi Virtual DOM&lt;/em&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Memanipulasi Virtual DOM
&lt;/h1&gt;

&lt;p&gt;Nah untuk memanipulasi Virtual DOM di Reactjs kita bisa memakai 2 cara yaitu :&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Menggunakan State&lt;/li&gt;
&lt;li&gt;Menggunakan Ref&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;kedua cara diatas akan kita praktekkan dalam kesempatan kali ini&lt;/p&gt;

&lt;h2&gt;
  
  
  1 Menggunakan State
&lt;/h2&gt;

&lt;p&gt;Untuk manipulasi Virtual DOM menggunakan state ini hanya bisa memanipulasi properti sederhana seperti mengganti class dan id.&lt;/p&gt;

&lt;p&gt;contoh :&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;di app.js kita inisialisasikan dulu state nya
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const [background, setBackground] = useState('red') 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;lalu kita buat component button yang akan mentrigger perubahan state nya
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;return (
    &amp;lt;div className="App"&amp;gt;
      &amp;lt;button className={background} onClick={changeBackground}&amp;gt;
        change Background
      &amp;lt;/button&amp;gt;
    &amp;lt;/div&amp;gt;
  ) 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;setelah itu kita buat function changeBackground untuk menghandle button ketika di klik
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const changeBackground = () =&amp;gt; {
    if(background === 'red'){
      setBackground('blue')
    }
    else{
      setBackground('red')
    }
  }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;lalu di app.css kita buat style untuk class nya
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;red{
  background: red;
}

.blue{
  background: rgb(99, 99, 255);
} 

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;hasilnya akan seperti dibawah&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.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%2Fm9elua0k6556w9d4tzgg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2Fm9elua0k6556w9d4tzgg.png" alt=" " width="186" height="46"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  1 Menggunakan Ref
&lt;/h2&gt;

&lt;p&gt;Cara yang kedua adalah menggunakan &lt;code&gt;ref&lt;/code&gt; atau singkatan dari &lt;code&gt;reference&lt;/code&gt;. ref ini adalah sebuah &lt;code&gt;referensi&lt;/code&gt; yang mengarah ke element HTML pada react. &lt;/p&gt;

&lt;p&gt;Jika kita ingin memanipulasi element Virtual DOM maka kita &lt;code&gt;tidak langsung&lt;/code&gt; memanipulasi elementnya, tapi yang kita manipulasi adalah &lt;code&gt;ref&lt;/code&gt; dari element tersebut. Oke langsung saja kita praktekkan&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;definisikan sebuah ref menggunakan &lt;code&gt;useRef&lt;/code&gt; jika menggunakan class component pakai &lt;code&gt;createRef&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const buttonRef = useRef();
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;lalu letakkan buttonRef diatas ke element yang ingin kita beri referensi&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; &amp;lt;button className={background} ref={buttonRef} onClick={changeBackground}&amp;gt;
        change Background
&amp;lt;/button&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;(masih menggunakan kodingan yang tadi ya). nah setelah itu di function &lt;code&gt;changeBackground()&lt;/code&gt; kita coba memodifikasi element buttonnya menggunakan ref. sebagai contoh saya akan mengubah textContent dari button ketika di click. jadi saya tuliskan seperti ini&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const changeBackground = () =&amp;gt; {
    if(background === 'red'){
      setBackground('blue')
      buttonRef.current.textContent = 'Berubah biru'
    }
    else{
      setBackground('red')
      buttonRef.current.textContent = 'Berubah Merah'
    }
  }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;nah hasilnya jika kita mengklik button maka background dan tulisan dalam button akan berubah&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.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%2Fibojozambjrkksott9xy.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2Fibojozambjrkksott9xy.png" alt=" " width="142" height="54"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Sekian dulu Tutorial dari saya. Jika ada salah kata mohon dimaafkan.  Jika ada pertanyaan silahkan hubungi&lt;br&gt;
&lt;a href="https://api.whatsapp.com/send?phone=+628976121070" rel="noopener noreferrer"&gt;Whatsapp&lt;/a&gt; &lt;a href="https://instagram.com/_satria_herman?utm_medium=copy_link" rel="noopener noreferrer"&gt;Instagram&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Wassalamu'alaikum Warahmatullahi Wabarakatuh &lt;/p&gt;

</description>
      <category>javascript</category>
      <category>react</category>
      <category>webdev</category>
      <category>programming</category>
    </item>
    <item>
      <title>Reactjs Overview - (EchLus Community - Part 1)</title>
      <dc:creator>satriaherman</dc:creator>
      <pubDate>Thu, 11 Nov 2021 07:17:39 +0000</pubDate>
      <link>https://dev.to/_satria_herman/reactjs-overview-echlus-community-a06</link>
      <guid>https://dev.to/_satria_herman/reactjs-overview-echlus-community-a06</guid>
      <description>&lt;p&gt;Halo kawan - kawan kali ini saya akan sharing materi tentang "Reactjs Overview". ini merupakan seri sharing session batch tentang Reactjs.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Overview Materi&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Di batch ini kita akan belajar tentang&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Install and Setup Reactjs&lt;/li&gt;
&lt;li&gt;Basic Props and State&lt;/li&gt;
&lt;li&gt;React Hooks&lt;/li&gt;
&lt;li&gt;React State Management&lt;/li&gt;
&lt;li&gt;Communicating With Server&lt;/li&gt;
&lt;li&gt;Esbuild&lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  1. Install dan Setup Reactjs
&lt;/h1&gt;

&lt;p&gt;Pada proses instalasi kita bisa melihatnya di &lt;a href="https://reactjs.org/docs/create-a-new-react-app.html" rel="noopener noreferrer"&gt;Sini&lt;/a&gt;. untuk instalasinya sebenarnya ada dua cara. yakni dengan menggunakan &lt;a href="https://www.niagahoster.co.id/blog/apa-itu-cdn/" rel="noopener noreferrer"&gt;CDN&lt;/a&gt;. atau dengan menggunakann Create React App(CRA).&lt;/p&gt;

&lt;p&gt;Untuk kesempatan kali ini saya akan menginstall React menggunakan CRA. oke langsung saja ke tutorial.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Buka Terminal atau CMD. lalu jalankan &lt;code&gt;npx i create-react-app belajar_react&lt;/code&gt; . npx sendiri kepanjangan dari node package execute. yang mana  jika dijalankan maka akan mengeksekusi package yang sudah maupun belum kita install. dengan menggunakan npx kita tidak perlu menginstall CRA ke dalam local computer kita.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;D:\programming\belajar Javascript\react&amp;gt;npx create-react-app belajar_react

Creating a new React app in D:\programming\belajar Javascript\react\belajar_react.

Installing packages. This might take a couple of minutes.
Installing react, react-dom, and react-scripts with cra-template...

[  ................] - fetchMetadata: sill resolveWithNewModule scheduler@0.20.2 checking installable stat
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;tunggu prosesnya sampai selesai&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;jika sudah selesai ketik perintah &lt;code&gt;cd belajar_react&lt;/code&gt;. lalu ketik perintah &lt;code&gt;code .&lt;/code&gt; agar membuka project kita di &lt;a href="https://code.visualstudio.com/" rel="noopener noreferrer"&gt;Visual Studio&lt;/a&gt;. &lt;/li&gt;
&lt;/ul&gt;

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