Skip to content

Commit ff459bc

Browse files
committed
Stop making diffs in every frame
1 parent d783daf commit ff459bc

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/history.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,11 @@ function CommitList({ commits, currentIndex, selectCommit }) {
8686
export default function History({ commits, language }) {
8787
const codes = commits.map(commit => commit.content);
8888
const slideLines = getSlides(codes, language);
89-
const [current, target, setTarget] = useSliderSpring(codes.length - 1);
89+
return <Slides slideLines={slideLines} commits={commits} />;
90+
}
91+
92+
function Slides({ commits, slideLines }) {
93+
const [current, target, setTarget] = useSliderSpring(commits.length - 1);
9094
const index = Math.round(current);
9195

9296
const nextSlide = () =>
@@ -116,6 +120,7 @@ export default function History({ commits, language }) {
116120
</React.Fragment>
117121
);
118122
}
123+
119124
function useSliderSpring(initial) {
120125
const [target, setTarget] = useState(initial);
121126
const tension = 0;

0 commit comments

Comments
 (0)