mirror of
https://github.com/storybookjs/storybook.git
synced 2025-04-04 20:51:07 +08:00
Merge pull request #16039 from storybookjs/fix/multiple-story-source-snippet
Addon-docs: Ensure we don't clobber multiple source container state updates
This commit is contained in:
commit
008867d787
@ -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