subtirelumihail / react-fullpage

A react implementation of fullpage.js
303 stars 105 forks source link

Active class doesn't add to first section anchor #18

Open declspec-cdecl opened 7 years ago

declspec-cdecl commented 7 years ago

If entered url without hash or with hash for first section then active class doesn't add to first section anchor. This behavior already exists in example app.

subtirelumihail commented 7 years ago

I wil check this out

EvgeniyPolovniy commented 7 years ago

Any fixes?

kejtizuki commented 6 years ago

Did u check it?

unaimian commented 6 years ago

Passing activeSection state over SectionsContainer to the parent and setting state (0 refers to the first anchor) in componentDidMount should solve this. Works fine for me.

Setting state in componentDidMount is not allowed according to eslint defaults but it seems quite legit in this case and not causing any visible troubles.

constructor(props){
  super(props);

  this.state = {
    activeSection: null
  };
}

componentDidMount() {
  this.setState({
    activeSection: 0
  });
}

render() {
  return (
    <SectionsContainer activeSection={this.state.activeSection} />
  );
}