<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Abdur Rakib on Medium]]></title>
        <description><![CDATA[Stories by Abdur Rakib on Medium]]></description>
        <link>https://medium.com/@abdur-rakib?source=rss-b1dfcf0f6ba5------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*EGBVJhs7GVK3UAfwzKF72A.jpeg</url>
            <title>Stories by Abdur Rakib on Medium</title>
            <link>https://medium.com/@abdur-rakib?source=rss-b1dfcf0f6ba5------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 27 Nov 2026 22:46:22 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@abdur-rakib/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[OWASP Top 10: What Every Developer Should Actually Know]]></title>
            <link>https://abdur-rakib.medium.com/owasp-top-10-what-every-developer-should-actually-know-f45b2a05371c?source=rss-b1dfcf0f6ba5------2</link>
            <guid isPermaLink="false">https://medium.com/p/f45b2a05371c</guid>
            <category><![CDATA[web-security]]></category>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[owasp-top-10]]></category>
            <category><![CDATA[backend-development]]></category>
            <dc:creator><![CDATA[Abdur Rakib]]></dc:creator>
            <pubDate>Sat, 18 Jul 2026 13:34:58 GMT</pubDate>
            <atom:updated>2026-07-18T13:34:58.421Z</atom:updated>
            <content:encoded><![CDATA[<p>Security is one of those topics most developers understand in theory but skip in practice.</p><p>We know we should hash passwords. We know SQL injection is bad. We’ve heard of OWASP. But when there’s a deadline, security becomes “something to handle later” — and later never quite arrives.</p><p>This post is what I put together while going deep on web application security. Every item on the OWASP Top 10 list, explained the way I wish someone had explained it to me — with real Node.js and NestJS examples, not abstract warnings.</p><p>If you’re building backend APIs, this is the checklist you actually want.</p><h3>What Is the OWASP Top 10?</h3><p>The Open Web Application Security Project (OWASP) publishes a ranked list of the most critical web application security risks, updated regularly based on data from real-world breaches across thousands of applications.</p><p>It’s not a list of exotic attack scenarios reserved for nation-state hackers. It’s a list of mistakes that happen in normal codebases built by experienced developers — because security wasn’t part of the design.</p><p>Let’s go through all ten.</p><h3>1. Broken Access Control</h3><p><strong>What it means:</strong> A user can access data or perform actions that belong to someone else or require higher privileges.</p><p>The classic example: you’re logged in as a user 123. You notice the URL says /api/users/123. You change it to /api/users/124. If the server returns that user&#39;s data, that&#39;s a broken access control.</p><p><strong>Vulnerable code:</strong></p><pre>@Get(&#39;:id&#39;)<br>getUser(@Param(&#39;id&#39;) id: string) {<br>  return this.userService.findOne(id);<br>  // No check: is this the requesting user&#39;s own ID?<br>}</pre><p>Any authenticated user can fetch any other user’s data by guessing or incrementing an ID.</p><p><strong>The fix — never trust the client for identity:</strong></p><pre>@Get(&#39;me&#39;)<br>getMyProfile(@Request() req) {<br>  // ID comes from the verified JWT, not from the URL<br>  return this.userService.findOne(req.user.id);<br>}</pre><p>For privileged routes, enforce role checks server-side:</p><pre>@UseGuards(RolesGuard)<br>@Roles(&#39;admin&#39;)<br>@Get(&#39;/users&#39;)<br>getAllUsers() {<br>  return this.userService.findAll();<br>}</pre><p>The rule: <strong>the server decides what a user can see — never the URL, never the frontend.</strong></p><h3>2. Cryptographic Failures</h3><p><strong>What it means:</strong> Sensitive data — passwords, tokens, personal information — is stored or transmitted without proper protection.</p><p>Common mistakes include storing passwords in plain text or with weak hashes like MD5, making API calls over HTTP instead of HTTPS, logging or storing tokens in localStorage, and exposing sensitive fields in API responses.</p><p><strong>Never do this:</strong></p><pre>const user = await db.save({ email, password }); // Plain text password</pre><p><strong>Always hash passwords with bcrypt:</strong></p><pre>import * as bcrypt from &#39;bcrypt&#39;;</pre><pre>const hashedPassword = await bcrypt.hash(password, 10);<br>const user = await db.save({ email, password: hashedPassword });</pre><pre>// Verification<br>const isValid = await bcrypt.compare(inputPassword, user.password);</pre><p>bcrypt is intentionally slow. That slowness is what makes brute-force attacks impractical — a GPU that cracks an MD5 hash in milliseconds takes years on a properly configured bcrypt hash.</p><p>Beyond passwords: always use HTTPS, never log sensitive fields, and encrypt PII at rest.</p><h3>3. Injection</h3><p><strong>What it means:</strong> Untrusted user input gets interpreted as part of a query or command, changing what it does.</p><p>SQL injection is the most well-known variant — but the same problem exists with NoSQL queries, shell commands, XML parsers, and anywhere else you mix user input with an interpreted language.</p><p><strong>Vulnerable — string concatenation into a query:</strong></p><pre>// If email = &quot;&#39; OR &#39;1&#39;=&#39;1&quot;, this returns every user in the database<br>const result = await db.query(<br>  `SELECT * FROM users WHERE email=&#39;${email}&#39;`<br>);</pre><p><strong>Fixed — parameterized query:</strong></p><pre>const result = await db.query(<br>  &#39;SELECT * FROM users WHERE email = $1&#39;,<br>  [email] // Treated as data, never executed as SQL<br>);</pre><p><strong>Better — use an ORM like Prisma:</strong></p><pre>// Prisma handles parameterization automatically<br>const user = await prisma.user.findFirst({<br>  where: { email }<br>});</pre><p>The principle: <strong>never concatenate user input into anything that gets interpreted or executed.</strong></p><h3>4. Insecure Design</h3><p><strong>What it means:</strong> The application’s architecture is missing fundamental security controls — not a bug in the code, but a gap in the design.</p><p>Examples: no rate limiting on login, no account lockout after failed attempts, no verification step before a password reset, no separation between admin and user capabilities.</p><p>You can’t patch your way out of insecure design. It has to be built in.</p><p><strong>The most common missing control — rate limiting on auth routes:</strong></p><pre>// npm install @nestjs/throttler<br>ThrottlerModule.forRoot([{<br>  ttl: 60000, // 60-second window<br>  limit: 5,   // 5 attempts max per window<br>}])</pre><pre>@UseGuards(ThrottlerGuard)<br>@Post(&#39;/login&#39;)<br>async login(@Body() dto: LoginDto) {<br>  return this.authService.login(dto);<br>}</pre><p>The habit to build: during feature design, ask — <em>what’s the worst thing someone could do with this, and what stops them?</em></p><h3>5. Security Misconfiguration</h3><p><strong>What it means:</strong> Insecure default settings, exposed debug tooling, permissive CORS, or verbose error messages that hand attackers information they shouldn’t have.</p><p>Common examples in Node.js projects:</p><ul><li>Swagger UI is exposed publicly in production</li><li>NODE_ENV not set to production</li><li>CORS set to *</li><li>Stack traces returned in error responses</li><li>Default credentials left unchanged</li></ul><p><strong>The baseline security setup for any NestJS app:</strong></p><pre>// main.ts</pre><pre>import helmet from &#39;helmet&#39;;</pre><pre>// Security headers — covers XSS, clickjacking, MIME sniffing, and more<br>app.use(helmet());</pre><pre>// Lock CORS to your actual domains<br>app.enableCors({<br>  origin: [&#39;https://myapp.com&#39;],<br>  credentials: true,<br>});</pre><pre>// Only expose API docs in development<br>if (process.env.NODE_ENV !== &#39;production&#39;) {<br>  const config = new DocumentBuilder().setTitle(&#39;API&#39;).build();<br>  SwaggerModule.setup(&#39;docs&#39;, app, SwaggerModule.createDocument(app, config));<br>}</pre><p>helmet() alone sets over a dozen protective HTTP headers. It costs one line to add and should be in every app you ship.</p><h3>6. Vulnerable and Outdated Components</h3><p><strong>What it means:</strong> You’re using dependencies with known security vulnerabilities. This is one of the most common ways production systems get compromised — not through the code you wrote, but through a library you installed.</p><p>A real pattern: an old version of a popular utility library has a prototype pollution vulnerability. It was patched six months ago. You haven’t updated. You’re running the vulnerable version.</p><p><strong>Make dependency auditing part of your routine:</strong></p><pre># Check for vulnerabilities<br>npm audit</pre><pre># Auto-fix safe updates<br>npm audit fix</pre><p>Set up <strong>Dependabot</strong> on GitHub (free). It automatically opens pull requests when your dependencies have security patches. Review, merge, done.</p><p>Also worth doing regularly: remove packages you no longer use. Every dependency you don’t need is a vulnerability you don’t have to worry about.</p><h3>7. Identification and Authentication Failures</h3><p><strong>What it means:</strong> Weak authentication mechanisms allow attackers to impersonate legitimate users. This includes JWTs that never expire, weak password requirements, missing MFA, and improperly stored session tokens.</p><p><strong>The wrong approach:</strong></p><pre>// Token with no expiry — valid indefinitely if stolen<br>jwt.sign(payload, secret);</pre><p><strong>The correct pattern — short-lived access tokens with refresh tokens:</strong></p><pre>// Access token: short-lived, stateless<br>const accessToken = jwt.sign(payload, secret, { expiresIn: &#39;15m&#39; });</pre><pre>// Refresh token: longer-lived, stored in httpOnly cookie, revocable server-side<br>const refreshToken = jwt.sign(<br>  { userId: user.id },<br>  refreshSecret,<br>  { expiresIn: &#39;7d&#39; }<br>);</pre><p>If an access token gets stolen, the attacker’s window is 15 minutes. Refresh tokens stored in httpOnly cookies are invisible to JavaScript — immune to XSS attacks — and can be invalidated when a user logs out.</p><p>Other controls to layer in: enforce minimum password length and complexity, block commonly used passwords, and implement MFA for sensitive operations.</p><h3>8. Software and Data Integrity Failures</h3><p><strong>What it means:</strong> Your application runs code or data from external sources without verifying that it hasn’t been tampered with.</p><p>Two common scenarios:</p><p><strong>1. CDN compromise</strong> — you load a script from a third-party CDN. If that CDN is compromised, every user of your app runs malicious code.</p><p><strong>2. Supply chain attack</strong> — a dependency you rely on gets a new maintainer who publishes a malicious version. You install it without noticing.</p><p><strong>Fix for CDN scripts — Subresource Integrity (SRI):</strong></p><pre>&lt;script<br>  src=&quot;https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js&quot;<br>  integrity=&quot;sha384-[hash-of-the-file]&quot;<br>  crossorigin=&quot;anonymous&quot;&gt;<br>&lt;/script&gt;</pre><p>The browser hashes the downloaded file and compares it to the integrity attribute. A single changed byte causes the script to be blocked entirely.</p><p><strong>Fix for build pipelines:</strong></p><pre># Use ci instead of install — respects the lockfile exactly<br>npm ci</pre><p>Commit your lockfile (package-lock.json or pnpm-lock.yaml) and never bypass it in CI.</p><h3>9. Security Logging and Monitoring Failures</h3><p><strong>What it means:</strong> Critical security events aren’t logged, aren’t centralized, or aren’t triggering alerts. Without proper monitoring, a breach can go undetected for months.</p><p>The events worth logging: authentication attempts (both success and failure), role changes, password resets, access to sensitive data, and unusual request patterns.</p><p><strong>Structured logging on auth events:</strong></p><pre>@Post(&#39;/login&#39;)<br>async login(@Body() dto: LoginDto, @Request() req) {<br>  const user = await this.authService.validateUser(dto);</pre><pre>  if (!user) {<br>    this.logger.warn(&#39;Authentication failed&#39;, {<br>      email: dto.email,<br>      ip: req.ip,<br>      timestamp: new Date().toISOString(),<br>    });<br>    throw new UnauthorizedException();<br>  }</pre><pre>  this.logger.log(&#39;Authentication succeeded&#39;, {<br>    userId: user.id,<br>    ip: req.ip,<br>  });</pre><pre>  return this.authService.generateTokens(user);<br>}</pre><p>Ship those logs to a centralized system — ELK stack, Loki, CloudWatch, or Datadog — and set alerts for patterns: five failed logins from one IP in two minutes, an admin accessing bulk records, a role elevation outside business hours.</p><p>Logging doesn’t prevent attacks. It limits how long an attack goes unnoticed.</p><h3>10. Server-Side Request Forgery (SSRF)</h3><p><strong>What it means:</strong> Your server makes HTTP requests to a URL provided by a user, and doesn’t validate where that URL points. An attacker can use this to make your server talk to internal services it should never be able to reach.</p><p>A well-known example: AWS instances have an internal metadata endpoint 169.254.169.254 that returns IAM credentials. If your server fetches any URL, an attacker can point it there.</p><p><strong>Vulnerable:</strong></p><pre>@Get(&#39;/fetch&#39;)<br>async fetch(@Query(&#39;url&#39;) url: string) {<br>  const response = await fetch(url); // Will fetch anything, including internal services<br>  return response.text();<br>}</pre><p><strong>Fixed — strict domain allowlist:</strong></p><pre>import { URL } from &#39;url&#39;;<br>import { BadRequestException } from &#39;@nestjs/common&#39;;</pre><pre>const ALLOWED_HOSTS = new Set([&#39;images.myapp.com&#39;, &#39;cdn.trusted-source.com&#39;]);</pre><pre>@Get(&#39;/fetch&#39;)<br>async fetch(@Query(&#39;url&#39;) rawUrl: string) {<br>  let url: URL;<br>  try {<br>    url = new URL(rawUrl);<br>  } catch {<br>    throw new BadRequestException(&#39;Invalid URL&#39;);<br>  }</pre><pre>  if (![&#39;http:&#39;, &#39;https:&#39;].includes(url.protocol)) {<br>    throw new BadRequestException(&#39;Protocol not allowed&#39;);<br>  }</pre><pre>  if (!ALLOWED_HOSTS.has(url.hostname)) {<br>    throw new BadRequestException(&#39;Host not allowed&#39;);<br>  }</pre><pre>  const response = await fetch(url.toString());<br>  return response.text();<br>}</pre><p>Use an allowlist, not a blocklist. Trying to block all internal IP ranges can be bypassed with DNS rebinding. Allowing only hosts you explicitly trust cannot.</p><h3>The Minimum Every NestJS App Should Have</h3><p>After going through all ten, here’s the practical baseline I apply to every Node.js backend I build:</p><pre>npm install @nestjs/throttler helmet bcrypt @nestjs/config</pre><p>In main.ts:</p><pre>app.use(helmet());<br>app.enableCors({ origin: [&#39;https://yourdomain.com&#39;], credentials: true });</pre><p>On auth routes: ThrottlerGuard, short-lived JWTs, bcrypt for password hashing.</p><p>In CI: npm audit on every pull request, Dependabot is enabled, npm ci instead of npm install.</p><p>In production: structured logging, centralized log aggregation, alerts on auth anomalies.</p><p>None of this is hard to implement. The difficulty is remembering to do it before you ship, not after.</p><h3>Summary</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*voP8ohUlrvOpz5x0Rk16og.png" /></figure><p>Security isn’t a feature you add at the end. It’s a set of habits you build into how you work. The OWASP Top 10 is a good place to start building them.</p><p><em>I’m a software engineer working on backend systems. I write about Node.js, NestJS, system design, and things I’m learning along the way.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f45b2a05371c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[React Interview Questions]]></title>
            <link>https://abdur-rakib.medium.com/react-interview-questions-ef9fa969d256?source=rss-b1dfcf0f6ba5------2</link>
            <guid isPermaLink="false">https://medium.com/p/ef9fa969d256</guid>
            <category><![CDATA[react]]></category>
            <category><![CDATA[interview-questions]]></category>
            <category><![CDATA[interview-prep]]></category>
            <category><![CDATA[interview-preparation]]></category>
            <category><![CDATA[interview-tips]]></category>
            <dc:creator><![CDATA[Abdur Rakib]]></dc:creator>
            <pubDate>Sat, 18 Feb 2023 03:13:43 GMT</pubDate>
            <atom:updated>2023-02-18T03:13:43.896Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*_zmHhBu-GIIvAUbj" /><figcaption>Photo by <a href="https://unsplash.com/es/@lautaroandreani?utm_source=medium&amp;utm_medium=referral">Lautaro Andreani</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Welcome to my new Interview Questions episode, In this episode, I will discuss about important react interview questions.</p><p><strong>What is React?</strong><br><strong>React</strong> is an open-source front-end JavaScript library that is used for building user interfaces, especially for single-page applications.</p><p><strong>What are the major features of React?</strong><br> — React uses Virtual DOM instead of Real DOM considering that Real DOM manipulations are expensive. <br>— Follows Unidirectional data flow or data binding. <br>— Uses reusable UI components to develop the view.</p><p><strong>What is JSX?</strong><br> <strong>JSX</strong> stands for javascript XML. By this, we can write javascript with HTML using this. Basically, it just provides syntactic sugar for the <em>React.createElement()</em>. JSX is an extension to JavaScript understood only by preprocessors like <em>Babel</em>. Once encountered by a preprocessor, this HTML-like text is converted into regular old function calls to <em>React.createElement().</em></p><p><strong>What is the difference between React Element &amp; Component?<br>React element</strong> is simply an object that represents a DOM node and its attributes/properties. It is immutable we can not apply any methods to it.<br><strong>React Component</strong> is a function or class which takes input(props) and returns <em>react element</em>.</p><p><strong>What is pure component?<br>PureComponent</strong> is exactly the same as <strong>Component</strong> except that it handles the shouldComponentUpdate() method for us. When props or state changes, PureComponent will do a shallow comparison on both props and state. Component on the other hand won’t compare current props and state to the next out of the box. Thus, the component will re-render by default whenever shouldComponentUpdate is called. <br>We can use <strong>React.memo()</strong> for writing pure components in functional components.</p><p><strong>What is State?<br></strong>A <strong>state</strong> is components own property, component can mutate state object . if state changes then the component gets re-rendered.</p><p><strong>What is Props in React?</strong><br><strong>Props</strong> are inputs to a component. It is just readable we should not mutate props. We use props to pass data from parent to children component.</p><p><strong>What is the difference between state and props?<br></strong>- States are components own property. On the other hands, props are input to a component.<br>- States are mutable and props are immutable. we should not manipulate props.</p><p><strong>Why we should not update the state directly?</strong><br>If you try to update the state directly then it won’t re-render the component. But if we change state using setState then components get re-rendered</p><p><strong>What is the purpose of the callback function as an argument of setState()?<br></strong>Whenever we need to update our current state to the next state based on the value passed by the property just now, then we have to use setState Callback.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2adcff2770ade199d94955e699e99071/href">https://medium.com/media/2adcff2770ade199d94955e699e99071/href</a></iframe><p>In this code if we press Update State button frequently 3 times then state updated to 1 not 3 because here we are trying to update state inside setTimeout which is asynchronous. When we are pressing Update state button then handleUpdate function forms a closure with current state value(0) and after timer ends inside setState we got 0 as state value. So we get updated state value as 0 + 1 = 1. We can solve this problem by using set state callBack. Inside setState callBack we get current state value. Below we will show how we can update state value using setState callback.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ae938f5edefdf72450a41336420b2a0e/href">https://medium.com/media/ae938f5edefdf72450a41336420b2a0e/href</a></iframe><p><strong>What is DOM?</strong><br><strong>DOM</strong> stands for <em>Document Object Model</em>. DOM is the tree representation of <em>HTML document</em>. Where each node represents the part of the document. Using vanilla js and DOM API we can access any html element. DOM manipulation is expensive.</p><p><strong>What is Virtual DOM?</strong><br><strong>Virtual DOM</strong> is a programming concept, which react uses to optimize the performance of applications. A virtual DOM is a lightweight JavaScript object which is a copy/blueprint of the real DOM, that is kept in memory. When a react application starts then react creates a virtual dom by copying the real dom and kept in memory. It has the same properties as the Real DOM, but it can not directly change the (DOM) content of the screen. If any data(state) changes then react automatically creates another virtual dom and update. (It’s an easy and fast process because virtual dom doesn’t need to paint the screen) After that react compares the previous virtual dom and updated virtual dom using an efficient <em>diffing</em> algorithm, and applies just updated changes to Real Dom. This process is also called <em>Reconciliation</em>.</p><p><strong>What are the limitations of React?</strong><br> — Weighing in at 133kb, React is considered to be a relatively heavy dependency. By comparison, Vue is 58kb. For this reason, React could be considered overkill for small apps. <br>— Compared to a framework like Angular, React doesn’t enforce strong opinions about how to write and structure your code or about which libraries to use for things like data fetching. In react for data-fetching we have to depend on additional data-fetching libraries like Axios or Fetch.</p><p><strong>Can you write React without JSX?</strong><br>Yes, we can. actually jsx is a syntactic sugar of <em>React.createElement().</em> Under the hood JSX calls the old function <em>React.createElement().</em></p><p><strong>How do you pass a value from parent to child?</strong><br>We can pass value parents to children by passing props to children components.</p><p><strong>How do you pass a value from the child to the parent component?<br></strong>To pass a value from a child component to a parent component, the parent must supply a function for the child component by which we can change/pass value to parent from child.</p><p><strong>What is prop drilling?</strong><br>When you pass a prop more than two components deep and the second component doesn’t actually need the data (it just passes it along), then it is called props drilling.</p><p><strong>What is the component lifecycle?<br></strong>i) Mount ii) Update ii) Unmount</p><p><strong>What is <em>useEffect</em> hook?<br>useEffect</strong> hook is used for handling side effects(handle async operation, DOM manipulation)<br>useEffect takes two arguments. <br>— The first argument is a function called <strong>effect</strong> and is what gives the useEffect Hook its name. <br>— The second argument is an optional array called dependencies which allows you to control when exactly the effect function is run. Think of dependencies as variables (typically state variables) that the effect function references and therefore depends on.<br>The useEffect hook either return undefined or a function called <em>cleanup</em> function(similar to <em>componentWillUnmount</em>). the <em>cleanUp</em> function runs before the next effect runs and before the component will unmount.</p><p><strong>When does use Effect function runs?</strong><br> — If we pass an empty array as dependency array ([]), the effect runs after the component is mounted (similar to componentDidMount)<br> — If we pass an array of state variables ([var]), the effect runs after the component is mounted, and anytime the values of these variables change<br> — If we omit the dependency array, then theeffect will run when the component is mounted and on each state change.</p><p><strong>What is the difference between refs and state variables?</strong><br> — Both persist values between renders<br> — If state changes then component re-renders, but ref don’t trigger re-render<br> — Ref is used for accessing DOM elements (focus input, selecting text, playback control)</p><p><strong>What is Fragment?</strong><br>Fragment is a newly-introduced component that supports returning multiple children from a component’s render method without needing an extraneous div element.</p><p><strong>When should you create class-based component vs a function component?</strong>we can use both ways. but if we want more control over component then we should use class based component.</p><p><strong>What are forward refs?</strong><br>By default, the ref prop only works on <em>HTML elements</em>, not on <em>React components</em>. When we want to pass down a ref to a React component, we need to tell React which HTML element it should reference.So to accept ref from child component , we need to wrap child component with <em>forwardRef</em> to accept ref as props.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6b7dfbbe4d7b112d4c209c9eb651b027/href">https://medium.com/media/6b7dfbbe4d7b112d4c209c9eb651b027/href</a></iframe><p><strong>What is useMemo Hook?</strong><br><strong>useMemo</strong> memoizes the return value of a expensive functions so that we can avoid calling them on every render. we simply pass our function and an array of inputs to <em>useMemo</em> and <em>useMemo</em> will only recompute the memoized value when one of the inputs has changed return memoized value.</p><p><strong>What is useCallback hook?</strong><br><strong>useCallback</strong> hook returns a memoized version of a function. Basically, it prevents a function to recreate after re-render. It keeps the function reference the same. This is useful when passing callbacks to optimized child components that rely on reference equality to prevent unnecessary renders.</p><p><strong>What is useContext hook?</strong><br>This hook takes the <em>context</em> as input and returns context value anywhere (Any component ) in the app.</p><p><strong>What is useReducer hook?</strong><br><strong>useReducer </strong>hook<strong> </strong>is like <em>useState</em>, for complex state management, we should use this hook. I have read a <a href="https://saadbashar.com/2021/07/31/%e0%a6%b8%e0%a6%b9%e0%a6%9c-%e0%a6%ac%e0%a6%be%e0%a6%82%e0%a6%b2%e0%a6%be%e0%a7%9f-react-hooks-%e0%a6%b8%e0%a6%bf%e0%a6%b0%e0%a6%bf%e0%a6%9c%e0%a5%a4-%e0%a6%aa%e0%a6%b0%e0%a7%8d%e0%a6%ac-%e0%a7%aa-u/">blog</a> regarding this hook, I think it will be helpful.</p><p><strong>What is useLayoutEffect?<br></strong><em>useEffect</em> and <em>useLayoutEffect</em> are kinds of the same. <br> — useEffect is asynchronous and useLayoutEffect is synchronous<br> — useEffect calls after mounting the component but useLayoutEffect calls before mounting the component. Useful <a href="https://blog.logrocket.com/underrated-react-hooks-youre-missing-out-on/#:~:text=The%20useImperativeHandle%20Hook%20allows%20us,DOM%20in%20a%20function%20component.">link</a> regarding underrated hooks.</p><p><strong>What is </strong><strong>useImperativeHandle hook? </strong><br>By using this hook we can access the child’s state, and function.<br>In React, data is passed from parent to child components via props, known as unidirectional data flow. The parent component cannot directly call a function defined in the child component or reach down to grab a value for itself.<br>In certain circumstances, we want our parent component to reach down to the child component, getting data that originates in the child component for its own use. We can achieve this type of data flow with the useImperativeHandle Hook, which allows us to expose a state or function inside a child component to the parent component through <em>ref</em>. We can also decide which properties or functions the parent component can access, thereby maintaining the private scoping of the child component.</p><p><strong>What are uncontrolled and controlled components?</strong><br> — Controlled component is a component whose value we can pass through and we can change the value of this component, this is a react way.<br>— Uncontrolled component which handles their own state, we can’t change/mutate their value only we can access their value by accessing DOM using <em>ref</em>. Useful <a href="https://goshacmd.com/controlled-vs-uncontrolled-inputs-react/">link</a>.</p><p><strong>What is useId hook?</strong><br>The main use case of the <em>useId</em> hook is <strong>to generate unique ids for use within HTML elements</strong>. The best example of this would be to create an id for input and have a label point to the same id.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/651ea6f5421952b1a0a4cd39c6f2df69/href">https://medium.com/media/651ea6f5421952b1a0a4cd39c6f2df69/href</a></iframe><p><strong>What are debounce and throttle?</strong><br>I think this <a href="https://leewarrick.com/blog/how-to-debounce/">link</a> will be more informative about this topic.</p><p><strong>Importance of keys in React list.</strong></p><p><strong>Optimize performance in React.js</strong></p><p><strong>What is portal in react?</strong></p><p><strong>What is Higher Order Component(HOC)?</strong></p><p><strong>Render Props Pattern</strong></p><p><strong>Composition vs inheritance in React?</strong></p><p><strong>What is React Profiler?</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ef9fa969d256" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Redux Interview Questions]]></title>
            <link>https://abdur-rakib.medium.com/redux-interview-questions-7fbe5ab2796b?source=rss-b1dfcf0f6ba5------2</link>
            <guid isPermaLink="false">https://medium.com/p/7fbe5ab2796b</guid>
            <category><![CDATA[redux]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[redux-toolkit]]></category>
            <category><![CDATA[context-api]]></category>
            <dc:creator><![CDATA[Abdur Rakib]]></dc:creator>
            <pubDate>Thu, 03 Nov 2022 04:11:01 GMT</pubDate>
            <atom:updated>2022-11-03T07:15:25.557Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>What is Redux? <br>Redux</strong> is an open-source JavaScript library for managing and centralizing application states. It is most commonly used with libraries such as React or Angular for building user interfaces. Similar to Facebook’s Flux architecture, it was created by <em>Dan Abramov</em> and <em>Andrew Clark</em>.</p><p><strong>How does redux work?<br>Redux</strong> has mainly three building parts. <br>i) <strong>Action</strong>: Action is a plain javascript object which contains a mandatory field <em>type</em> and a minor field <em>payload.</em><br>ii) <strong>Store: </strong>Store is a global object which holds the whole state of our application<br>iii)<strong>Reducer:</strong> Reducer is a function that takes an <em>action</em> and <em>previous state</em> and returns a <em>new state</em>.<br><strong>Dispatch:</strong> Dispatch is a redux function. If any event occurs in view then redux dispatches an action with type and payload which is sent to the reducer and the reducer change state depending on the action.<br><strong>State update mechanism:</strong> Basically, in any application, we have three things such as <em>view, action, and state</em>. In view, if any event occurred like a click then it dispatches an action with type and payload. Then reducer listens to the action and changes the state depending on the action type and after changing the state View re-renders.</p><p><strong>What is redux-thunk?<br>Redux Thunk</strong> is a middleware that lets us call action creators that return a function instead of just actions (In this function we can call API and change our redux state depending on the response) instead of an action object. This middleware is used for handling asynchronous operations (delayed actions, including working with promises).</p><p><strong>What is redux enhancer?</strong><br><strong>Redux enhancers</strong> are high-order functions that take <em>createStore</em> as input and return a new enhanced version of <em>createStore.</em></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d2d44a2adf6fa92d763bbdd1ad190446/href">https://medium.com/media/d2d44a2adf6fa92d763bbdd1ad190446/href</a></iframe><p><strong>How does redux persist work?</strong><br><strong>Redux persist</strong> is a library allowing us to save the redux store in the local storage of your browser/AsyncStorage for react native. When our app launches, redux sets an initial state. Shortly after this, redux persist retrieves our persisted state from storage. Our persisted state then overrides any initial state.</p><p><strong>Redux vs React Context, When should we use what?<br></strong>We should use context for those data which don’t change frequently like theme data, localization data e.t.c. Because if any state changes in a context then all consumers of this context will re-render, whether a consumer’s consumed value changed or not, the consumer will re-render.<br>And we should use redux when, <br>- our application is very big and contains complex states<br>- we want to have greater control over states and actions in our applications.<br>- we want middleware for various purposes (logging actions, error reporting, dispatching other requests depending on the server’s response, etc.)<br>- we want to persist our state.<br>- and if we don’t want server response to directly change the state of our application.</p><blockquote><strong>Useful Links: </strong><br>- <a href="https://www.shawndsilva.com/blog/web-development/differences-between-redux-and-redux-toolkit-and-why-should-you-upgrade">https://www.shawndsilva.com/blog/web-development/differences-between-redux-and-redux-toolkit-and-why-should-you-upgrade</a><br>- <a href="https://leewarrick.com/blog/the-problem-with-context/">https://leewarrick.com/blog/the-problem-with-context/</a><br>- <a href="https://stackoverflow.com/questions/49568073/react-context-vs-react-redux-when-should-i-use-each-one">https://stackoverflow.com/questions/49568073/react-context-vs-react-redux-when-should-i-use-each-one</a></blockquote><p>Thanks for reading. Any comments will be appreciated. <br>Stay safe &amp; happy, bye.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7fbe5ab2796b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Object Oriented Programming in JavaScript(ES6)]]></title>
            <link>https://abdur-rakib.medium.com/object-oriented-programming-in-javascript-es6-70304e8c6816?source=rss-b1dfcf0f6ba5------2</link>
            <guid isPermaLink="false">https://medium.com/p/70304e8c6816</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[oop]]></category>
            <category><![CDATA[typescript]]></category>
            <dc:creator><![CDATA[Abdur Rakib]]></dc:creator>
            <pubDate>Wed, 02 Nov 2022 13:19:44 GMT</pubDate>
            <atom:updated>2023-02-09T09:31:07.248Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>What is OOP? </strong><br>Object Oriented Programming (OOP) is a programming paradigm that relies on classes and objects. Classes are like blueprints and objects are like instances of a class.<br>Some topics we should know before moving on to details.<br><strong>Class: </strong>Classes are blueprints from which we can create/instantiate objects. Classes can have attributes and methods.<br><strong>Object: </strong>Objects are instance of a class, that behaves like variables.<br><strong>Constructor: </strong>Constructor is a method of a class, which is invoked at the time of object creation. It initializes the state of objects.<br><strong>Destructor:</strong> Destructors are automatically invoked at the end of the lifetime of an object. Destructors are usually used to deallocate memory and do cleanup for an object when an object destroys. A destructor is called for a class object when that object passes out of scope or is explicitly deleted.</p><p><strong>Basic Principles of OOP?</strong> <strong><br></strong>Basically, there are 4 main principles of OOP. Abstraction, inheritance, encapsulation, Polymorphism. Here, we will discuss briefly these topics with examples in TypeScript.<br><strong> Encapsulation: </strong>Encapsulation is wrapping up the data into a single unit. It reduces complexity and increases reusability.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8fe67724a25a62aa0dfe100d4d790208/href">https://medium.com/media/8fe67724a25a62aa0dfe100d4d790208/href</a></iframe><p><strong>Abstraction: </strong>An abstraction is a way of hiding the implementation details and showing only the functionality to the users. Reduce complexity from users.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/45faf32572fb8dd132b82050bc2b9788/href">https://medium.com/media/45faf32572fb8dd132b82050bc2b9788/href</a></iframe><p>Here, we create a method a method called <em>createVehicle </em>which<em> </em>contains all functionalities of creating a vehicle. After creating an object with this class we can just create a vehicle with the <em>createVehicle</em> method, we don’t need to know the functionality of this method. This is abstraction actually.</p><p><strong>Inheritance:</strong> Inheritance is the procedure in which one class can inherit the attributes and methods of another class. It helps to eliminate redundant code.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GZIxlXJ3_mXaX3cGuBVQJg.png" /><figcaption>Inheritance</figcaption></figure><p>In this example, Person is our parent class. Another class <em>Student</em> inherits from <em>Person</em>, which means the <em>Student</em> class can access attributes and methods from the <em>Person</em> class. That’s why we can access the <em>great</em> method at <em>student1</em> obj which is instantiated from <em>Student</em>.</p><p><strong>Polymorphism:</strong> The word polymorphism means having many forms. In simple words, we can define polymorphism as the ability of a message to be displayed in more than one form. <br>A real-life example of polymorphism: A person at the same time can have different characteristics. Like a man at the same time is a father, a husband, and an employee. So the same person possesses different behavior in different situations. This is called polymorphism. It helps to refactor ugly switch/case statements.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8dJPoMfKem48722KC6_nFg.png" /><figcaption>Polymorphism</figcaption></figure><p>There are two types of polymorphism.<br>1. Method Overriding(Runtime polymorphism)<br>2. Method Overloading(Compile-time polymorphism)<br><strong>Method Overriding:</strong> Declaring a method in a sub-class that is already present in the parent class is known as method overriding. In the method overriding the data types of arguments, no of arguments and sequence must be exactly the same as the parent method. It is also known as runtime polymorphism. (<em>Late Binding</em>)<br><strong>Method Overloading:</strong> Method overloading is a feature that allows a class to have multiple methods with the same name but their argument list must be different. It is also known as compile-time polymorphism. (<em>Early Binding</em>)</p><p><strong>What is Static Method?</strong><br>The static method of a class is only bound to the class, so we can not use this with an instance of a class but can use this directly with the class.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zHz33sfLxwK6Uo-qfXPfSw.png" /></figure><p><strong>Access Modifier:</strong> Access modifiers in a class are used to set up accessibility (Visibility) for the class members.</p><p>There are three types of access modifiers:<br><strong> Public:</strong> All the class members declared under the <em>public</em> modifier will be available to everyone.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UC3zaodDqD6rd43EB7gIRg.png" /></figure><p><strong>Private</strong>: The class members declared as <em>private</em> can be accessed only by the member functions inside the class.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KcZY8LcE4FdBhc7XR91m5Q.png" /></figure><p><strong>Protected: </strong>The protected modifiers are also similar to private but they can also be accessed from their own class and any sub-class of that class.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8VdnwryNICFSo1ap-LxTZQ.png" /></figure><p><strong>Singleton Design Pattern Implementation using TypeScript<br>Singleton </strong>pattern is a software design pattern that restricts the instantiation of a class to a singular instance.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/575/1*UY8UA1y-_-ojwoXHiaX9EA.png" /></figure><p>Welcome to read this article, and any comments &amp; suggestions are welcome.<br>By the way, this is my first article on Medium.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=70304e8c6816" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>