Bird
Raised Fist0
Reactframework~20 mins

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

Choose your learning style10 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.

Practice

(1/5)
1. What is the main reason to organize React files into folders like components, pages, and hooks?
easy
A. To make the app run faster
B. To reduce the file size of the app
C. To keep the project easy to understand and maintain
D. To avoid using React hooks

Solution

  1. Step 1: Understand folder organization purpose

    Folders like components and hooks group related files by their role.
  2. Step 2: Recognize benefits of clear structure

    This grouping makes the project easier to read and maintain for developers.
  3. Final Answer:

    To keep the project easy to understand and maintain -> Option C
  4. Quick Check:

    Folder organization = easier maintenance [OK]
Hint: Folders group related files for clarity and ease [OK]
Common Mistakes:
  • Thinking folder structure affects app speed
  • Confusing file size with organization
  • Believing hooks folder is optional for React hooks
2. Which of the following is the correct way to organize a React project folder for components?
easy
A. Put all components in a single components folder
B. Scatter components randomly in the root folder
C. Put components inside the public folder
D. Put components inside the node_modules folder

Solution

  1. Step 1: Identify standard folder for components

    React projects usually keep components in a dedicated components folder.
  2. Step 2: Avoid incorrect placements

    Components should not be in public or node_modules folders, which serve other purposes.
  3. Final Answer:

    Put all components in a single components folder -> Option A
  4. Quick Check:

    Components folder = centralized components [OK]
Hint: Keep components together in one folder [OK]
Common Mistakes:
  • Placing components in public folder
  • Scattering components without structure
  • Modifying node_modules folder
3. Given this folder structure:
src/
  components/
    Button.jsx
  hooks/
    useToggle.js
  pages/
    Home.jsx

Which file would you expect to find the custom React hook?
medium
A. src/components/Button.jsx
B. src/pages/Home.jsx
C. src/index.js
D. src/hooks/useToggle.js

Solution

  1. Step 1: Understand folder naming conventions

    Custom hooks are usually placed in the hooks folder.
  2. Step 2: Match file to folder purpose

    The file useToggle.js inside hooks matches the custom hook naming pattern.
  3. Final Answer:

    src/hooks/useToggle.js -> Option D
  4. Quick Check:

    Custom hooks in hooks folder = useToggle.js [OK]
Hint: Hooks go in the hooks folder [OK]
Common Mistakes:
  • Looking for hooks in components folder
  • Confusing pages folder with hooks
  • Assuming index.js contains hooks
4. You see this folder structure in a React project:
src/
  components/
    Header.jsx
  utils/
    helpers.js
  Header.jsx

What is the main problem here?
medium
A. Having a utils folder is not recommended
B. Duplicate Header.jsx file in root and components folder causes confusion
C. Components should be inside utils folder
D. Files should not have .jsx extension

Solution

  1. Step 1: Identify duplicate file names

    There are two Header.jsx files: one in components and one in root.
  2. Step 2: Understand confusion caused by duplicates

    This duplication can confuse developers and cause import errors.
  3. Final Answer:

    Duplicate Header.jsx file in root and components folder causes confusion -> Option B
  4. Quick Check:

    Duplicate filenames = confusion [OK]
Hint: Avoid duplicate filenames in different folders [OK]
Common Mistakes:
  • Thinking utils folder is bad practice
  • Believing components belong in utils
  • Ignoring file extensions importance
5. You are building a large React app. Which folder structure best supports growth and easy maintenance?
hard
A. Organize by feature: each feature folder contains components, hooks, and styles
B. Put all files in one big folder to avoid complexity
C. Separate files only by file type, ignoring features
D. Keep all components and hooks mixed in the root folder

Solution

  1. Step 1: Understand feature-based organization

    Grouping by feature means each feature folder holds all related files, making it easier to find and update.
  2. Step 2: Compare with other structures

    Flat or type-only folders become hard to manage as app grows, causing confusion.
  3. Final Answer:

    Organize by feature: each feature folder contains components, hooks, and styles -> Option A
  4. Quick Check:

    Feature folders = scalable and maintainable [OK]
Hint: Group by feature for scalable projects [OK]
Common Mistakes:
  • Using one big folder causes clutter
  • Separating only by file type slows feature updates
  • Mixing all files in root is confusing
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard