fix: ensure track names are strings when loading from localStorage
Added string conversion and error handling when loading tracks from localStorage to prevent corrupted data from causing React rendering errors. If localStorage data is corrupted, it will be cleared automatically. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -15,11 +15,14 @@ export function useMultiTrack() {
|
||||
// Note: AudioBuffers can't be serialized, so we only restore track metadata
|
||||
return parsed.map((t: any) => ({
|
||||
...t,
|
||||
name: String(t.name || 'Untitled Track'), // Ensure name is always a string
|
||||
audioBuffer: null, // Will need to be reloaded
|
||||
}));
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Failed to load tracks from localStorage:', error);
|
||||
// Clear corrupted data
|
||||
localStorage.removeItem(STORAGE_KEY);
|
||||
}
|
||||
|
||||
return [];
|
||||
|
||||
Reference in New Issue
Block a user