0
0
Reactframework~20 mins

Folder structure best practices in React - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Folder Structure Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
component_behavior
intermediate
2:00remaining
How does this folder structure affect component imports?

Given this React folder structure:

src/
  components/
    Button/
      Button.jsx
      Button.css
    Header/
      Header.jsx
      Header.css
  App.jsx

What is the correct import statement for Button inside Header.jsx?

Aimport Button from '../Button.jsx';
Bimport Button from './Button.jsx';
Cimport Button from '../Button/Button.jsx';
Dimport Button from '../../Button/Button.jsx';
Attempts:
2 left
💡 Hint

Think about relative paths from Header folder to Button folder.

📝 Syntax
intermediate
2:00remaining
Which folder structure supports scalable React features?

Which folder structure below best supports adding new features with isolated components and logic?

A
src/
  components/
    Button.jsx
    Header.jsx
  utils/
    helpers.js
B
src/
  components/
    Button/
      index.jsx
      styles.css
    Header/
      index.jsx
      styles.css
C
src/
  utils/
    api.js
    helpers.js
  components/
    Button.jsx
    Header.jsx
D
src/
  features/
    login/
      LoginForm.jsx
      loginSlice.js
    dashboard/
      Dashboard.jsx
      dashboardSlice.js
Attempts:
2 left
💡 Hint

Think about grouping by feature to keep related files together.

🔧 Debug
advanced
2:00remaining
Why does this import fail in this folder structure?

Given this folder structure:

src/
  components/
    common/
      Button.jsx
  pages/
    Home.jsx

Inside Home.jsx, this import is used:

import Button from '../../components/common/Button';

Why might this cause an error?

AThe file extension .jsx must be included in the import.
BThe relative path is incorrect; it should be '../components/common/Button'.
CButton.jsx is missing a default export.
DThe components folder should be inside pages for this import to work.
Attempts:
2 left
💡 Hint

Check how many folders up Home.jsx is from components.

🧠 Conceptual
advanced
2:00remaining
What is the main benefit of grouping by feature in React projects?

Why do many React projects organize folders by feature (e.g., login, dashboard) instead of by file type (e.g., components, utils)?

AIt makes it easier to find and update all code related to a single feature.
BIt reduces the total number of files in the project.
CIt enforces using only functional components.
DIt automatically improves app performance.
Attempts:
2 left
💡 Hint

Think about how developers work on features.

state_output
expert
3:00remaining
How does folder structure impact React state management clarity?

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.js

What is the main advantage of this structure for understanding app state?

AEach feature folder contains its own state logic, making state changes easier to track and debug.
BAll state logic is centralized in one file, reducing complexity.
CState is managed globally without separation, improving performance.
DState files are placed outside features to avoid coupling with UI components.
Attempts:
2 left
💡 Hint

Think about how grouping state with UI helps developers.