public render()

in adapters/react/RuiScrollToReact/src/RuiScrollTo.tsx [25:52]


	public render(): JSX.Element {
		const {disableAnimation, scrollContainer, children, ...otherProps} = this.props;
		const props = otherProps;
		if (disableAnimation) {
			props['disable-animation'] = true;
		}

		if (scrollContainer) {
			props['scroll-container'] = scrollContainer;
		}

		// will throw an error if number of children is not === 1
		// otherwise will return only child
		const firstChild = React.Children.only(children);

		// need to add slot to the given child
		let triggerEl: ReactNode = null;
		if (firstChild) {
			triggerEl = addExtraProps(firstChild, {slot: 'scroll-trigger'});
			//TriggerEl = React.cloneElement(firstChild, {slot: 'scroll-trigger'});
		}

		return (
			<rui-scroll-to {...props}>
				{triggerEl}
			</rui-scroll-to >
		);
	}