0
0
Reactframework~10 mins

Component naming rules in React - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to define a React component with a proper name.

React
function [1]() {
  return <div>Hello!</div>;
}
Drag options to blanks, or click blank then click option'
AMyComponent
B123Component
Cmycomponent
Dcomponent
Attempts:
3 left
💡 Hint
Common Mistakes
Starting component names with lowercase letters.
Using names that start with numbers.
2fill in blank
medium

Complete the code to export a React component with a correct name.

React
const [1] = () => {
  return <p>Hi!</p>;
};

export default [1];
Drag options to blanks, or click blank then click option'
AhelloWorld
Bhelloworld
CHelloWorld
Dhello_world
Attempts:
3 left
💡 Hint
Common Mistakes
Using camelCase or snake_case for component names.
Using all lowercase names.
3fill in blank
hard

Fix the error in the component name to follow React naming rules.

React
export function [1]() {
  return <span>Test</span>;
}
Drag options to blanks, or click blank then click option'
ASecondComponent
Bsecond_component
CsecondComponent
D2ndComponent
Attempts:
3 left
💡 Hint
Common Mistakes
Starting names with numbers.
Using camelCase or snake_case.
4fill in blank
hard

Fill both blanks to correctly define and export a React component.

React
const [1] = () => {
  return <h1>Welcome</h1>;
};

export default [2];
Drag options to blanks, or click blank then click option'
AWelcomePage
BwelcomePage
Cwelcome_page
D1Welcome
Attempts:
3 left
💡 Hint
Common Mistakes
Mismatch between component and export names.
Using lowercase or invalid names.
5fill in blank
hard

Fill all three blanks to create a valid React component and export it.

React
import React from 'react';

function [1]() {
  return <section>[2]</section>;
}

export default [3];
Drag options to blanks, or click blank then click option'
AUserProfile
B"User Profile"
DuserProfile
Attempts:
3 left
💡 Hint
Common Mistakes
Using lowercase or camelCase for component names.
Not quoting string content inside JSX.
Mismatch between function and export names.