Preact: this.props.children an empty array in nested react-router route

Created on 30 Sep 2016  路  2Comments  路  Source: preactjs/preact

This has only started since v6.1.0

import { options, h, render } from 'preact';
import { hashHistory, Route, Router, Redirect } from 'react-router';

class App extends Component {
  render() {
    return (
      <Router history={ hashHistory }>
        <Route path="main" component={ MainPage }>
          <Route path="connect" component={ ConnectTab } />
          <Route path="saved" component={ SavedTab } />
        </Route>
        <Redirect from="/" to="/main/connect" />
      </Router>
    );
  }
}

class MainPage extends Component {
  render() {
    return (
      <div className="mainPage">
        <header><h1>App name</h1></header>
        { this.props.children }
      </div>
    );
  }
}

render(<App />, document.getElementById('app'));

In 6.1.0 this.props.children is []

bug compat

Most helpful comment

So I've tracked this down: preact-compat changes VNode.children to be only a VNode instead of an Array (as React components expect). However, in 6.1.0 the algorithm for flattening children changed and it ended up not accounting for this case. I've got a fix, I'm just tweaking the size and checking performance.

All 2 comments

So I've tracked this down: preact-compat changes VNode.children to be only a VNode instead of an Array (as React components expect). However, in 6.1.0 the algorithm for flattening children changed and it ended up not accounting for this case. I've got a fix, I'm just tweaking the size and checking performance.

Fix released in 6.2 馃懐

Was this page helpful?
0 / 5 - 0 ratings

Related issues

nopantsmonkey picture nopantsmonkey  路  3Comments

paulkatich picture paulkatich  路  3Comments

k15a picture k15a  路  3Comments

kossnocorp picture kossnocorp  路  3Comments

kay-is picture kay-is  路  3Comments