Skip to content

fix: references to the window object instead of state history in story #2624

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions stories/useStateWithHistory.story.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const Demo = () => {
return;
}

window.history.back(stepSize);
history.back(stepSize);
},
[history, stepSize]
);
Expand All @@ -35,7 +35,7 @@ const Demo = () => {
return;
}

window.history.forward(stepSize);
history.forward(stepSize);
},
[history, stepSize]
);
Expand All @@ -60,12 +60,12 @@ const Demo = () => {
Current state: <span>{state}</span>
</div>
<div style={{ marginTop: 8 }}>
<button onClick={handleBackClick} disabled={!window.history.position}>
<button onClick={handleBackClick} disabled={!history.position}>
&lt; Back
</button>
<button
onClick={handleForwardClick}
disabled={window.history.position >= window.history.window.history.length - 1}>
disabled={history.position >= history.history.length - 1}>
Forward &gt;
</button>
&nbsp; Step size:&nbsp;
Expand All @@ -76,7 +76,7 @@ const Demo = () => {
<div>Current history</div>
<div
dangerouslySetInnerHTML={{
__html: JSON.stringify(window.history.history, null, 2)
__html: JSON.stringify(history.history, null, 2)
.replace(/\n/g, '<br/>')
.replace(/ /g, '&nbsp;'),
}}
Expand Down