Old reply, but someone is bound to run into the same error.
When you're passing the context as a prop in the base WebPart, make sure you're passing it by using the this.context.
Passing the WebPartContext prop from the base web part component to the child component:
export default class SpTestAppWebPart extends BaseClientSideWebPart {
public render() {
const element = React.createElement(
SpTestApp,
{
description: this.properties.description,
ctx: this.context
}
);
}
Then inside the child component, you should be able to use the WebPartContext on the props passed to it:
export default class SpTestApp extends React.Component {
public render() {
return (
<div className={ styles.spTestApp }>
<div className={ styles.container }>
<p>{this.props.ctx.pageContext.web.absoluteUrl}</p>
</div>
</div>
</div>
);
}
}