remotion-dev/remotion · error · Error

useTimelineRowContainsSelection must be used inside…

Error message

useTimelineRowContainsSelection must be used inside TimelineSelectionProvider

What it means

useTimelineRowContainsSelection reports whether a Timeline row contains the current selection. It requires TimelineRowSelectionContext and throws this error when invoked outside TimelineSelectionProvider.

Solutions

  1. Render the consuming component inside <TimelineSelectionProvider>.
  2. Inspect the React tree to confirm the provider is an ancestor of the hook caller.
  3. Move the hook call into the part of the tree that sits under the provider, or lift state usage differently.
  4. Diff your Timeline customizations against upstream to restore provider nesting.

Example fix

// before
export const MyRow = () => { useTimelineRowContainsSelection(p); ... };
// after — render MyRow inside the provider
<TimelineSelectionProvider><MyRow /></TimelineSelectionProvider>
Defensive patterns

Strategy: validation

Validate before calling

// only call in components mounted under TimelineSelectionProvider
const contains = useTimelineRowContainsSelection(path); // must be within provider

Try / catch

try {
  computeContains();
} catch (e) {
  if (e.message.includes('useTimelineRowContainsSelection must be used inside')) {
    return false; // safe default outside provider
  }
  throw e;
}

Prevention

When it happens

Trigger: Calling useTimelineRowContainsSelection in a custom row or layout component rendered outside the Timeline selection provider subtree, or after refactoring removed/reordered the provider.

Common situations: Customizing Studio's Timeline layout; reusing a row component in another panel; provider order changed while merging upstream Studio changes.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


AI-assisted analysis of remotion-dev/remotion@46a3a6bf13 (2026-09-18). Data as JSON: /api/errors/f02dd38c485c3b6d. Report an issue: GitHub.

Appendix: source

Thrown at packages/studio/src/components/Timeline/TimelineSelection.tsx:1785

		(): TimelineSelection => ({
			type: 'guide',
			guideId,
		}),
		[guideId],
	);
	return useTimelineSelectionItem({
		revealInInspector: false,
		selectionItem,
		useSelectionOrder: false,
	});
};

export const useTimelineRowContainsSelection = (
	nodePathInfo: SequenceNodePathInfo | null,
): boolean => {
	const selectionContext = useContext(TimelineRowSelectionContext);
	if (selectionContext === null) {
		throw new Error(
			'useTimelineRowContainsSelection must be used inside TimelineSelectionProvider',
		);
	}

	const getContainsSelection = useCallback(() => {
		if (nodePathInfo === null) {
			return false;
		}

		return selectionContext
			.getSnapshot()
			.selectedItems.some(
				(selected) =>
					selected.type !== 'guide' &&
					nodePathDescendsFrom(selected.nodePathInfo, nodePathInfo),
			);
	}, [nodePathInfo, selectionContext]);

View on GitHub (pinned to 46a3a6bf13)