Skip to content

Deprecated URLInIconImages

Miklós Fazekas edited this page Apr 1, 2023 · 2 revisions

Using images/urls directly in styles

Deprecated:

<SymbolLayer style={{iconImage: require('foo.png')}} />
<SymbolLayer style={{iconImage: 'https://download.samplelib.com/png/sample-red-100x75.png'}} />

Replacement:

<Images images={{foo: require('foo.png')}} />
<SymbolLayer style={{iconImage: 'foo'}}/>
<Images images={{foo: 'sample-red-100x75.png'}} />
<SymbolLayer style={{'sample-red-100x75.png':   'https://download.samplelib.com/png/sample-red-100x75.png'}}/>

Why?

Required a lot of extra code, and it's esp. an issue since image loading is async, also it's a leaky abstraction as doesn't work with expressions:. The alternative is more flexible.