fr

Daily Challenge 🗓️

Your daily dose of technical intelligence to shine in (developer) society.

Discover a software development quiz per day with its detailed correction.

Frontend, Backend, Mobile, Data, Web, AI, Infra... Everything that can be coded!

Friday 27 March 2026

-

React ⚛️

React ⚛️ #14/45

What is the outcome of executing the following React code (using the useContext hook)?

import React, { createContext, useContext } from 'react';
import MyCustomButton from 'somewhere';

const ThemeContext = createContext('light');

function ThemedButton() {
  const theme = useContext(ThemeContext);
  return <MyCustomButton theme={theme}>Theme: {theme}</MyCustomButton>;
}

function App() {
  return (
    <ThemeContext.Provider value='dark'>
      <ThemedButton />
    </ThemeContext.Provider>
  );
}
Author: W3D TeamStatus: PublishedQuestion passed 2149 times
8
Reviews from developers
developer avatar
Auteur anonyme
06/04/2023
le bouton ne s'affiche pas je crois que c'est la bonne réponse car il manque l'élément export au niveau de la ligne 11 exprt function App() {
developer avatar
Auteur anonyme
11/09/2023
We cannot pass property 'theme' to the button component.
developer avatar
Auteur anonyme
07/11/2023
I updated the question.

About Daily Challenge 🗓️

From Monday to Friday, discover each day a quiz question with its detailed answer to enrich your tech knowledge. The questions are proposed by the WeLoveDevs.com community: experienced developers, trainers and freelancers.WeLoveDevs.com helps developers to find their dream job. We also provide over 50 free technical tests in different technologies for those of you who would like to test your knowledge.

History

    ⚠️
    Your browser is badly|not supported!
    We recommend you to use a more modern browser such as Edge, Chrome or Firefox
    Know More