mirror of
https://github.com/RealKai42/qwerty-learner.git
synced 2026-04-04 22:09:04 +08:00
fix: reset selected chapter after dict change (#401)
This commit is contained in:
@@ -1,14 +1,19 @@
|
||||
import React from 'react'
|
||||
import { range } from 'lodash'
|
||||
import ChapterButton from './ChapterButton'
|
||||
import { useAtom, useAtomValue } from 'jotai'
|
||||
import { currentChapterAtom, currentDictInfoAtom } from '@/store'
|
||||
import { CHAPTER_LENGTH } from '@/constants'
|
||||
import { currentChapterAtom, currentDictInfoAtom } from '@/store'
|
||||
import { useAtom, useAtomValue } from 'jotai'
|
||||
import { range } from 'lodash'
|
||||
import React from 'react'
|
||||
import { useUpdateEffect } from 'react-use'
|
||||
import ChapterButton from './ChapterButton'
|
||||
|
||||
const ChapterGroup: React.FC<ChapterGroupProps> = ({ totalWords }) => {
|
||||
const [currentChapter, setCurrentChapter] = useAtom(currentChapterAtom)
|
||||
const currentDictInfo = useAtomValue(currentDictInfoAtom)
|
||||
|
||||
useUpdateEffect(() => {
|
||||
setCurrentChapter(0)
|
||||
}, [currentDictInfo, setCurrentChapter])
|
||||
|
||||
return (
|
||||
<main className="mr-4 grid gap-4 sm:grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4">
|
||||
{range(currentDictInfo.chapterCount).map((index) =>
|
||||
|
||||
Reference in New Issue
Block a user