developit / developit/react-router-4-test

Switch does not work

Đang mở
#7 0 bình luận 0 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
JavaScript
Star
35
Fork
7
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

**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.

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.