Skip to content

Commit

Permalink
fix: current story useEffect delay
Browse files Browse the repository at this point in the history
  • Loading branch information
atanasster committed Aug 30, 2020
1 parent b3bfa73 commit 63a837c
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions core/store/src/state/context/story.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,9 @@ export const StoryContextProvider: FC<{ storyId: string | undefined }> = ({
children,
}) => {
const { store } = useContext(StoreContext);
const [story, setStory] = useState<Story | undefined>(
const [, setStory] = useState<Story | undefined>(
storyId ? store.stories[storyId] : undefined,
);
useEffect(() => {
setStory(storyId ? store.stories[storyId] : undefined);
}, [storyId, store]);
useEffect(() => {
const onObserver = (updatedStory?: Story) => {
if (updatedStory?.id === storyId) {
Expand All @@ -47,7 +44,7 @@ export const StoryContextProvider: FC<{ storyId: string | undefined }> = ({
return (
<StoryContext.Provider
value={{
story,
story: storyId ? store.stories[storyId] : undefined,
updateStory: newValue => {
if (storyId) {
store.updateStory(newValue);
Expand Down

0 comments on commit 63a837c

Please sign in to comment.