---
title: "Discussion on \"Let's code a Virtual DOM!\" | Hashnode"
description: "Discussion on \"Let's code a Virtual DOM!\". How to create your own React (kind of...)"
url: "https://hashnode.com/posts/lets-code-a-virtual-dom/6254a9d46386ed96b050b69c"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [Let's code a Virtual DOM!](https://kkalamarski.me/lets-code-a-virtual-dom?utm_source=hashnode&utm_medium=feed)

How to create your own React (kind of...)

Apr 11, 2022 · 5 min read · kkalamarski.me  
Read the article

-   [#reactjs](https://hashnode.com/tag/reactjs)
-   [#vuejs](https://hashnode.com/tag/vuejs)
-   [#virtual-dom](https://hashnode.com/tag/virtual-dom)
-   [#redux](https://hashnode.com/tag/redux)
-   [#typescript](https://hashnode.com/tag/typescript)

## Written by

[Krzysztof Kałamarski](https://hashnode.com/@kkalamarski)

@kkalamarski · Wrocław, Poland

  
[View profile](https://hashnode.com/@kkalamarski)

Fullstack Javascript Developer @ Exlabs

🚀 CTO &amp; Co-founder at Techfinity Studio — AI-driven software studio 👨‍💻 Full-stack developer, technical leader For the past 11 years, I’ve been building modern software solutions — today as the CTO and co-founder of Techfinity Studio, where we help companies build smart, efficient, and secure digital products. We use the right mix of technologies — from custom software to AI-driven solutions and low-code platforms — to deliver real business value. 💡 Key areas of expertise: • TypeScript, React, Next.js, Node.js, NestJS • AI integration &amp; AI-driven apps • Security-first architecture • Functional Programming I’m passionate about building great software and helping organizations navigate the rapidly evolving tech landscape. Outside of work, I enjoy ♟️ playing chess and exploring the intersection of technology and creativity. 🌍 I work in an international environment. Languages: 🇵🇱 Polish (native) 🇬🇧 English (fluent) 🇪🇸 Spanish (fluent) 🇵🇹 Portuguese (good) 🇧🇬 Bulgarian (communicative) 🤝 If you’d like to connect to discuss: • building modern digital products • applying AI where it makes sense • designing secure and scalable architecture • or simply exchange ideas on technology Feel free to reach out!

## Responses 7

Markdown supported · ⌘↵ to post

[raddevus](https://hashnode.com/@raddevus)

[Apr 15, 2022](https://hashnode.com/posts/lets-code-a-virtual-dom/6254a9d46386ed96b050b69c/comment/625987b92f84e0d4fc33b935)

Are you sure this code works?

`const app = document.querySelector<HTMLDivElement>('#app')!;`

I think you need to remove <HTMLDivElement> & the ! right before the semicolon.

I think it is supposed to be: `const app = document.querySelector('#app');`

[Krzysztof Kałamarski](https://hashnode.com/@kkalamarski)

[Apr 15, 2022](https://hashnode.com/posts/lets-code-a-virtual-dom/6254a9d46386ed96b050b69c/comment/625987b92f84e0d4fc33b935#reply-62598bd752fb7bd53380d416)

hey [raddevus](https://hashnode.com/@raddevus), thanks for commenting :)

All code I used in this post is a valid TypeScript code.

The `!` is a non-null assertion operator - [see the docs](https://www.typescriptlang.org/docs/handbook/2/everyday-types.html#non-null-assertion-operator-postfix-).

But you are right, if you want to run this code in the browser you need to remove typescript-specific syntax (like type annotation and `!`)

[raddevus](https://hashnode.com/@raddevus)

[Apr 15, 2022](https://hashnode.com/posts/lets-code-a-virtual-dom/6254a9d46386ed96b050b69c/comment/625987b92f84e0d4fc33b935#reply-6259c0432f84e0d4fc33bfe6)

[Krzysztof Kałamarski](https://hashnode.com/@kkalamarski) Ahh...TypeScript Ok, got it.

[Tomek](https://hashnode.com/@Tomekcl)

[Apr 14, 2022](https://hashnode.com/posts/lets-code-a-virtual-dom/6254a9d46386ed96b050b69c/comment/6258823552fb7bd53380b8a9)

Well explained. Endless possibilities in such an easy concept. Waiting for next parts!

[Arjit Sharma](https://hashnode.com/@arjitsharma32)

[Apr 13, 2022](https://hashnode.com/posts/lets-code-a-virtual-dom/6254a9d46386ed96b050b69c/comment/625709bce58c4ac41a675864)

Easy examples, and an interesting read 💫

[Diego Ballesteros (Relatable Code)](https://hashnode.com/@diegoballesteros)

[Apr 13, 2022](https://hashnode.com/posts/lets-code-a-virtual-dom/6254a9d46386ed96b050b69c/comment/6256d1bee58c4ac41a67534c)

Excellent write-up. Very easy to understand.

[Raman Sharma](https://hashnode.com/@raman-sharma)

[Apr 13, 2022](https://hashnode.com/posts/lets-code-a-virtual-dom/6254a9d46386ed96b050b69c/comment/625660c7b32ddd968bbecc72)

nice and clean explanation

[Randy Knight](https://hashnode.com/@RandyKnight)

[Apr 12, 2022](https://hashnode.com/posts/lets-code-a-virtual-dom/6254a9d46386ed96b050b69c/comment/6255eaf36386ed96b050d70a)

This is excellent information. I look forward to reading more of this series. 😎

[Iva Kop](https://hashnode.com/@IvaKop)

[Apr 12, 2022](https://hashnode.com/posts/lets-code-a-virtual-dom/6254a9d46386ed96b050b69c/comment/6255c37a6386ed96b050d32f)

Super nice and understandable explanation! Keep it up 🚀
