Skip to content

Commit 688a20c

Browse files
committed
Documentation and minor correction
1 parent c0fa067 commit 688a20c

File tree

3 files changed

+9
-5
lines changed

3 files changed

+9
-5
lines changed

src/components/challenges/VideoSection.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ const VideoSection = ({ challenge }) => {
2424
const hasMultiParts = challenge.parts?.length > 0;
2525
const [showTimestamps, setShowTimestamps] = useState(!hasMultiParts);
2626

27-
const activePartIndex = useChallengePartIndex(challenge.parts?.length ?? 1);
27+
const activePartIndex = useChallengePartIndex(challenge.parts?.length || 1);
2828
const activePart = challenge.parts?.[activePartIndex] ?? challenge;
2929
const { videoId, nebulaSlug, timestamps } = activePart;
3030
const hasTimestamps = timestamps?.length > 0;

src/components/tracks/VideoSection.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ const VideoSection = ({ track, video, trackPosition, mainTitle }) => {
3535

3636
const { title, topics, languages } = video;
3737

38-
const totalParts = video.parts?.length ?? 1;
38+
const totalParts = video.parts?.length || 1;
3939
const partIndex = useChallengePartIndex(totalParts);
4040
const part = video.parts?.[partIndex];
4141
const videoId = part?.videoId ?? video.videoId;

src/hooks/index.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -139,9 +139,13 @@ export const useIsFirstRender = () => {
139139
};
140140

141141
/**
142-
* Returns the challenge part index (0 if the challenge is not multi-part)
143-
* which has been stored in the `location.state` object using the `Link.state`
144-
* property.
142+
* If the current URL (and hash value) corresponds to a part from a multi-part
143+
* coding challenge (within a challenge page or a track page), this hook returns
144+
* the zero-based index of this part, else it returns 0.
145+
*
146+
* The hash value should look like `#part-3`. If the part number if larger than
147+
* the `totalParts` parameter, the returned index corresponds to the last part
148+
* of the challenge (`totalParts - 1`).
145149
*
146150
* @param totalParts {number} total number of parts of the challenge (1 if the
147151
* challenge is not multi-part)

0 commit comments

Comments
 (0)