Given this React folder structure:
src/
components/
Button/
Button.jsx
Button.css
Header/
Header.jsx
Header.css
App.jsxWhat is the correct import statement for Button inside Header.jsx?
Think about relative paths from Header folder to Button folder.
Since Header.jsx is inside Header/ and Button.jsx is inside sibling folder Button/, the relative path is ../Button/Button.jsx.
Which folder structure below best supports adding new features with isolated components and logic?
Think about grouping by feature to keep related files together.
Option D groups code by feature, keeping components and state logic together, which helps scaling and maintenance.
Given this folder structure:
src/
components/
common/
Button.jsx
pages/
Home.jsxInside Home.jsx, this import is used:
import Button from '../../components/common/Button';
Why might this cause an error?
Check how many folders up Home.jsx is from components.
Home.jsx is inside pages/. To reach components/common/Button.jsx, you must go up one level: from pages/ to src/, then into components/common/. So the correct path is ../components/common/Button.
Why do many React projects organize folders by feature (e.g., login, dashboard) instead of by file type (e.g., components, utils)?
Think about how developers work on features.
Grouping by feature keeps all related code together, making it simpler to maintain, test, and update features without hunting through many folders.
Consider a React app using Redux Toolkit with this folder structure:
src/
features/
cart/
Cart.jsx
cartSlice.js
products/
Products.jsx
productsSlice.js
app/
store.jsWhat is the main advantage of this structure for understanding app state?
Think about how grouping state with UI helps developers.
Keeping state logic (like slices) inside the feature folder groups UI and state together. This makes it easier to understand how state affects that feature and simplifies debugging.