Design Patterns · Junior · Question 37 of 75

What pattern does a custom hook useWindowSize() implement?

Explanation

Hooks replaced HOCs and render props for reusing logic: the component calls a function and gets data without piling up wrappers. Inside, the hook subscribes to resize and unsubscribes itself (the Observer pattern).

Further reading

Problem with a question

Design Patterns · Junior · question 37

Test yourself

Take the Design Patterns · Junior quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz