Click in order · JavaScript and React course · Module 4: Context API and useReducer

Custom Hook Pattern

Arrange the custom hook for context:

Items to click

  • if (!context) throw new Error('useSpaceStation must be used within SpaceProvider');
  • const context = useContext(SpaceContext);
  • }
  • function useSpaceStation() {
  • return context;

You can check the correct answer by solving this task in the CodeWorlds game.