BingMapsImageryProvider not working

I’m trying to add BingMapsImageryProvider using a newly created API key but I keep getting the error An error occurred while rendering. Rendering has stopped. What is the right way to add the imagery to my react app?

const addBingMapsImageryProvider = () => {
try {
var bingMapsImageryProvider = new BingMapsImageryProvider({
url: ‘//’,
key: ‘my newly created API key’,
mapStyle: BingMapsStyle.AERIAL

  if (viewer) {
catch (error) {
  console.error('Error in addBingMapsImageryProvider:', error);

This is my code. Tell me what I am doing wrong?

Hi there,

Try using BingMapsImageryProvider.fromUrl instead, rather than the constructor directly.