In the local SvelteKit template
In the template, use a reactive $state variable bound to a <textarea> instead of setting the textarea value directly:
let draw: TerraDraw | undefined = $state();
+let selectedFeature: string = $state('');
<hr />
<label for="selected-feature-geojson">Selected Feature GeoJSON:</label>
<textarea
id="selected-feature-geojson"
bind:value={selectedFeature}
style="width: 100%; resize: vertical;"
rows="10"
readonly
></textarea>
draw?.on('select', (id: TerraDrawExtend.FeatureId) => {
const feature = draw?.getSnapshotFeature(id);
selectedFeature = feature ? JSON.stringify(feature, null, 2) : '';
});
draw?.on('deselect', () => {
selectedFeature = '';
});