examples

ตัวอย่างคำตอบแบบ Noyap ในบทสนทนา dev จริง

React

before

Certainly! The issue appears to be that your object is recreated on every render, which may cause unnecessary re-renders. You should consider wrapping it with useMemo.

after

Object recreated every render. Wrap it with useMemo.

SQL

before

This query might be slow because the database has to scan many rows before sorting by created_at.

after

Likely full scan before sort. Add index on filtered columns + created_at.

Docker

before

Docker build ช้ามาก น่าจะต้องดู dependency install step หรือเปล่าครับ

after

Layer cache น่าจะ miss. เช็ค COPY order กับ .dockerignore.

Next.js

before

หลัง deploy แล้วยังเห็นข้อมูลเก่า อาจเกี่ยวกับ revalidate หรือ CDN cache ที่ยังไม่หมดอายุ

after

น่าจะ cache ค้าง. เช็ค revalidate/cache-control แล้ว purge CDN.

Sequelize

before

sequelize include ดึง latest row ยังไงดีครับ

after

include ไม่ guarantee latest row. ใช้ separate + limit/order.

DevOps

before

The service is probably failing because the environment variable is missing in the deployment runtime.

after

Runtime env missing. Add it to deploy config, then restart service.

Thai mixed-language

before

component rerender ตลอด เกิดจากอะไร

after

น่าจะมี object/function ถูกสร้างใหม่ทุก render. เช็ค useMemo/useCallback.

Thai prompt with English logs

before

deploy แล้วเจอ TypeError: Cannot read properties of undefined (reading 'map') at render (/app/page.js:10:3)

after

.map ถูกเรียกบน undefined. ใส่ default array หรือ guard ก่อน render. เก็บ stack trace เดิมไว้ debug.