mirror of
https://github.com/storybookjs/storybook.git
synced 2025-04-03 05:04:51 +08:00
Ensure we don't clobber multiple source container state updates
This commit is contained in:
parent
a3089466e5
commit
dd0821c491
@ -21,11 +21,14 @@ export const SourceContainer: FC<{}> = ({ children }) => {
|
||||
useEffect(() => {
|
||||
const handleSnippetRendered = (id: StoryId, newItem: SourceItem) => {
|
||||
if (newItem !== sources[id]) {
|
||||
const newSources = { ...sources, [id]: newItem };
|
||||
setSources((current) => {
|
||||
const newSources = { ...current, [id]: newItem };
|
||||
|
||||
if (!deepEqual(sources, newSources)) {
|
||||
setSources(newSources);
|
||||
}
|
||||
if (!deepEqual(current, newSources)) {
|
||||
return newSources;
|
||||
}
|
||||
return current;
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user