developit / developit/react-router-4-test

Switch does not work

オープン
#7 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る
主要言語
JavaScript
スター
35
フォーク
7
PR マージ指標
30日以内にマージされた PR はありません

説明

**Edit: Just realized pull request /pull/2 is exactly about this**

react-router's [Switch](https://reacttraining.com/react-router/web/api/Switch) looks for a function `Children.forEach` which isn't there. If I try to shim it by
```
Children.forEach = (c, f) => c.forEach(f);
```
then it looks for a function `React.isValidElement`, When it is shimmed as `const isValidElement = (e) => true;`, Switch starts to look for the component's props but the VNode doesn't have it, so Children.forEach should be

```
Children.forEach = (C, f) => {
const compat = C.map(c => ({...c, props: { path: c.attributes.path }}));
return compat.forEach(f);
}
```

which finally results in a `props.match` object returned from Switch. However, one would rather import `preact-compat` instead of rewriting it.

Don't know how this would be solved other than using `preact-compat` when `Switch` or other complex routing elements are needed.

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。