Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

scrollToY not working on componentDidMount #18

Open
santiagopuentep opened this issue Mar 3, 2017 · 0 comments
Open

scrollToY not working on componentDidMount #18

santiagopuentep opened this issue Mar 3, 2017 · 0 comments

Comments

@santiagopuentep
Copy link

I'm a component to create a scrolled div that on componentDidMount completely scrolls (100% from the top).

The problem is that it doesn't scroll on componentDidMount.

If I use setInterval inside componentDidMount with a few miliseconds delay to call scrollToY it does scroll.

The component:

import React from "react";
import ReactScrollbar from 'react-scrollbar-js';

const ScrolledText = React.createClass({
	propTypes: {
		text: React.PropTypes.string.isRequired
	},
	
	componentDidMount() {
		if (this.scrollBar) {
			this.scrollBar.scrollToY("100%");
		}
	},
	
	saveScrollBarRef(ref) {
		this.scrollBar = ref;
	},
	
	render() {
		const { text } = this.props;
		
		return (
			<ReactScrollbar
				ref={this.saveScrollBarRef}
				style={{
					height: "100%"
				}}
			>
				<div>{text}</div>
			</ReactScrollbar>
		);
	}
});

export default ScrolledText ;

I'm using it inside a simple div with a set height like this:

<div style={{height: "25px"}}>
	<EditionTextArea
		text={myLongText}
	/>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant