Stock

Stock

140 bookmarks
Newest
Introducing Valibot, a 1kb Zod Alternative
Introducing Valibot, a 1kb Zod Alternative
A schema can be compared to a type definition in TypeScript. The big difference is that TypeScript types are "not executed" and are more or less a DX feature. A schema on the other hand, apart from the inferred type definition, can also be executed at runtime to guarantee type safety of unknown data.
·builder.io·
Introducing Valibot, a 1kb Zod Alternative
Mental model
Mental model
Valibot's mental model is mainly divided between schemas, methods, and actions. Since each functionality is imported as its own function, it is crucial to understand this concept as it makes working with the modular API design much easier.
Schemas are the starting point for using Valibot. They allow you to validate a specific data type, like a string, object, or date. Each schema is independent. They can be reused or even nested to reflect more complex data structures.
Methods help you either modify or use a schema.
Actions help you to further validate or transform a specific data type. They are used exclusively in conjunction with the pipe method, which extends the functionality of a schema by adding additional validation and transformation rules.
·valibot.dev·
Mental model
サーバコンポーネント – React
サーバコンポーネント – React
サーバコンポーネントはブラウザに送信されないため、useState のようなインタラクティブな API を使用できません。
React Server Components の “server” とはこの別の環境を指しています。サーバコンポーネントは、CI サーバでビルド時に一度だけ実行することも、ウェブサーバを使用してリクエストごとに実行することもできます。
·ja.react.dev·
サーバコンポーネント – React
メモリー管理 - JavaScript | MDN
メモリー管理 - JavaScript | MDN
プログラミング言語に関係なく、メモリーのライフサイクルはほぼいつも同じです。 必要なメモリーを割り当てる 割り当てられたメモリーを使用する(読み込む, 書き込む) 必要なくなったら、割り当てられたメモリーを解放する
·developer.mozilla.org·
メモリー管理 - JavaScript | MDN
'use client' ディレクティブ – React
'use client' ディレクティブ – React
ファイルのトップに 'use client' を加えることで、当該モジュールとそれが連動してインポートしている依存モジュールがクライアントコードであるとマーク
クライアントコンポーネントとは、レンダーツリーの中の、クライアントでレンダーされるコンポーネントです。 サーバコンポーネントとは、レンダーツリーの中の、サーバでレンダーされるコンポーネントです。
サーバコンポーネントにより、クライアントに送信され実行されるコードの量を減らすことができます。バンドルされてクライアントで評価されるのはクライアントモジュールだけです。
サーバコンポーネントにはサーバ上で実行されることに伴う利点があります。ローカルファイルシステムにアクセスでき、データフェッチやネットワークリクエストのレイテンシが低い可能性があります。
サーバコンポーネントからクライアントコンポーネントに渡される props の値は、シリアライズ可能 (serializable) である必要があります。
サーバコンポーネントはユーザによるインタラクションをサポートできません。イベントハンドラはクライアントで登録されトリガされる必要があるためです。
クライアントコンポーネントとは、レンダーツリーの中の、クライアントでレンダーされるコンポーネントです。
コンポーネントモジュールに 'use client' ディレクティブが含まれている場合、そのコンポーネントは必ずクライアントコンポーネントであることが保証されます。
·ja.react.dev·
'use client' ディレクティブ – React
Design Docs
Design Docs
“When should you make a design document? ... If the change is large/cross-cutting, eg. will be spread over multiple PRs”
Writing forces clarity of thought. Think through major technical challenges before writing code.
Design docs are lightweight planning documents written before implementing code to solicit feedback, derive alignment, and create documentation.
·designdocs.dev·
Design Docs
JavaScriptのカスタムエラーはこれでOK | Wantedly Engineer Blog
JavaScriptのカスタムエラーはこれでOK | Wantedly Engineer Blog
それは、コードをminifyしたときに this.name の内容も一緒に変化してしまうからです。 最初に示したコード例のように名前を文字列リテラルとして明示することで、minifyされずにエラー名を保持することができます。強い難読化の必要がなければ、エラー名はそのまま保持するほうがよいでしょう。
·wantedly.com·
JavaScriptのカスタムエラーはこれでOK | Wantedly Engineer Blog
You Should Write
You Should Write
1. Writing is everywhere
Well-written content is like a personal assistant looking for opportunities for you 24/7. It showcases your knowledge, skills, and expertise to the readers and helps you draw more visibility to your products and services.
Writing forces you to step back, look at the bigger picture, and consider other perspectives. That helps you to spot gaps in your thinking, identify biases, and fix inaccurate assumptions.
·catalins.tech·
You Should Write