# พื้นฐาน React (React / Next.js) > JSX, components, props, state, อีเวนต์, conditional rendering, รายการและ keys - 20 คำถามสัมภาษณ์ - Junior - [คำถามสัมภาษณ์: React / Next.js](https://sharpskill.dev/th/technologies/react-next/interview-questions.md) ## 1. JSX ใน React คืออะไร? **คำตอบ** JSX เป็นส่วนขยายไวยากรณ์ของ JavaScript ที่ช่วยให้สามารถเขียน markup คล้าย HTML ได้โดยตรงในโค้ด JavaScript โดยจะถูกแปลงเป็นการเรียกฟังก์ชัน React.createElement โดย Babel ในระหว่างการคอมไพล์ การใช้ JSX ทำให้โค้ดอ่านง่ายขึ้นและสามารถตรวจจับข้อผิดพลาดได้ในเวลาคอมไพล์ผ่าน typing พร้อมทั้งรวมพลังของ JavaScript เข้ากับไวยากรณ์ที่คุ้นเคย ## 2. ไวยากรณ์ใดถูกต้องสำหรับการใช้นิพจน์ JavaScript ใน JSX? **คำตอบ** วงเล็บปีกกาเดี่ยวช่วยให้สามารถรวมนิพจน์ JavaScript ที่ถูกต้องใดๆ เข้าไปใน JSX ได้ เช่น ตัวแปร ฟังก์ชัน หรือการคำนวณ ไวยากรณ์นี้สร้างขอบเขตที่ชัดเจนระหว่าง JSX markup และโค้ด JavaScript แบบไดนามิก วงเล็บปีกกาคู่ใช้สำหรับอ็อบเจกต์ style inline วงเล็บกลมใช้สำหรับจัดกลุ่ม JSX หลายบรรทัด และวงเล็บเหลี่ยมใช้สำหรับ array ของ JavaScript ## 3. ความแตกต่างหลักระหว่าง className ใน JSX กับ class ใน HTML คืออะไร? **คำตอบ** JSX ใช้ className แทน class เนื่องจาก class เป็นคำสงวนใน JavaScript สำหรับการประกาศคลาส ES6 เนื่องจาก JSX ถูกแปลงเป็น JavaScript การใช้ class จะทำให้เกิดความขัดแย้งของไวยากรณ์ ในทำนองเดียวกัน for จะกลายเป็น htmlFor และอีเวนต์จะใช้ camelCase ข้อตกลงนี้ช่วยให้ JSX ยังคงเป็น JavaScript ที่ถูกต้องในขณะที่มีไวยากรณ์คล้าย HTML ## มีอีก 17 คำถาม - วิธีเขียนคอมเมนต์ในโค้ด JSX ทำอย่างไร? - Functional component ใน React คืออะไร? สมัครฟรี: https://sharpskill.dev/th/login ## หัวข้อสัมภาษณ์ React / Next.js อื่นๆ - [พื้นฐาน JavaScript](https://sharpskill.dev/th/technologies/react-next/interview-questions/javascript-essentials.md): 25 คำถาม, Junior - [React Hooks](https://sharpskill.dev/th/technologies/react-next/interview-questions/react-hooks.md): 22 คำถาม, Junior - [วงจรชีวิตของ component](https://sharpskill.dev/th/technologies/react-next/interview-questions/component-lifecycle.md): 18 คำถาม, Junior - [React Router](https://sharpskill.dev/th/technologies/react-next/interview-questions/react-router.md): 20 คำถาม, Junior - [การจัดการ state ด้วย Context](https://sharpskill.dev/th/technologies/react-next/interview-questions/state-management-context.md): 18 คำถาม, Junior - [ฟอร์มและ Controlled Components](https://sharpskill.dev/th/technologies/react-next/interview-questions/forms-controlled-components.md): 20 คำถาม, Mid-Level - [การดึงข้อมูลและ API](https://sharpskill.dev/th/technologies/react-next/interview-questions/fetching-data-api.md): 20 คำถาม, Mid-Level - [React Query (TanStack Query)](https://sharpskill.dev/th/technologies/react-next/interview-questions/react-query-tanstack.md): 20 คำถาม, Mid-Level - [Styling & CSS-in-JS](https://sharpskill.dev/th/technologies/react-next/interview-questions/styling-css-in-js.md): 18 คำถาม, Mid-Level - [พื้นฐาน Next.js](https://sharpskill.dev/th/technologies/react-next/interview-questions/nextjs-fundamentals.md): 25 คำถาม, Mid-Level - [TypeScript กับ React](https://sharpskill.dev/th/technologies/react-next/interview-questions/typescript-react.md): 20 คำถาม, Mid-Level - [การดึงข้อมูล Next.js](https://sharpskill.dev/th/technologies/react-next/interview-questions/nextjs-data-fetching.md): 24 คำถาม, Mid-Level - [Server Actions ของ Next.js](https://sharpskill.dev/th/technologies/react-next/interview-questions/nextjs-server-actions.md): 20 คำถาม, Mid-Level - [การกำหนดเส้นทางและการนำทางใน Next.js](https://sharpskill.dev/th/technologies/react-next/interview-questions/nextjs-routing-navigation.md): 22 คำถาม, Mid-Level - [API Routes ใน Next.js](https://sharpskill.dev/th/technologies/react-next/interview-questions/nextjs-api-routes.md): 20 คำถาม, Mid-Level - [Metadata & SEO ใน Next.js](https://sharpskill.dev/th/technologies/react-next/interview-questions/nextjs-metadata-seo.md): 18 คำถาม, Mid-Level - [Middleware และ Auth ใน Next.js](https://sharpskill.dev/th/technologies/react-next/interview-questions/nextjs-middleware-auth.md): 22 คำถาม, Mid-Level - [การทดสอบ React](https://sharpskill.dev/th/technologies/react-next/interview-questions/react-testing.md): 20 คำถาม, Mid-Level - [Zustand State Management](https://sharpskill.dev/th/technologies/react-next/interview-questions/zustand-state-management.md): 18 คำถาม, Mid-Level - [การเพิ่มประสิทธิภาพ React](https://sharpskill.dev/th/technologies/react-next/interview-questions/react-performance-optimization.md): 22 คำถาม, Senior - [Error Boundaries & การจัดการข้อผิดพลาด](https://sharpskill.dev/th/technologies/react-next/interview-questions/react-error-boundaries.md): 18 คำถาม, Senior - [Advanced React Patterns](https://sharpskill.dev/th/technologies/react-next/interview-questions/advanced-react-patterns.md): 20 คำถาม, Senior - [ฟีเจอร์ขั้นสูงของ Next.js](https://sharpskill.dev/th/technologies/react-next/interview-questions/nextjs-advanced-features.md): 24 คำถาม, Senior - [การ Deploy & Production ของ Next.js](https://sharpskill.dev/th/technologies/react-next/interview-questions/nextjs-deployment-production.md): 20 คำถาม, Senior - [Architecture & Design Patterns](https://sharpskill.dev/th/technologies/react-next/interview-questions/react-architecture-patterns.md): 22 คำถาม, Senior - [React Server Components](https://sharpskill.dev/th/technologies/react-next/interview-questions/react-server-components.md): 26 คำถาม, Senior - [การแปลภาษา Next.js](https://sharpskill.dev/th/technologies/react-next/interview-questions/nextjs-internationalization.md): 20 คำถาม, Senior - [React ความปลอดภัย & แนวปฏิบัติที่ดีที่สุด](https://sharpskill.dev/th/technologies/react-next/interview-questions/react-security-best-practices.md): 22 คำถาม, Senior --- Source: SharpSkill (https://sharpskill.dev), tech interview preparation for your real stack. HTML version of this page: https://sharpskill.dev/th/technologies/react-next/interview-questions/react-fundamentals