Have you tried in your component something like this:
static contextType = HeaderHeightContext;
componentDidMount() {
console.log(this.context); // this is your height
}
From documentation:
The contextType property on a class can be assigned a Context object created by React.createContext(). This lets you consume the nearest current value of that Context type using this.context
CLICK HERE to find out more related problems solutions.