From 139ed994358bb3c81c00e0951f4ebe41af3412fe Mon Sep 17 00:00:00 2001 From: rafalages Date: Thu, 24 Sep 2020 16:48:10 -0300 Subject: [PATCH] Add support for Preact X --- package.json | 2 +- src/index.js | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index 44e7e3e..750a91c 100644 --- a/package.json +++ b/package.json @@ -68,7 +68,7 @@ "mocha": "^3.0.0", "npm-run-all": "^4.0.1", "phantomjs-prebuilt": "^2.1.7", - "preact": "^7.2.0", + "preact": "^10.5.2", "pretty-bytes-cli": "^1.0.0", "rimraf": "^2.5.1", "rollup": "^0.41.4", diff --git a/src/index.js b/src/index.js index 9be47ff..0ec5ee0 100644 --- a/src/index.js +++ b/src/index.js @@ -1,4 +1,4 @@ -import { h, cloneElement, Component } from 'preact'; +import { h, cloneElement, Component, toChildArray } from 'preact'; /** @example * @@ -32,7 +32,7 @@ export class Views extends Component { // Render the child whose `name` prop matches the current view render({ children }, { view, params }) { - let child = children.filter( child => child.attributes.name===view )[0]; + let child = toChildArray(children).filter( child => child.props.name===view )[0]; return child ? cloneElement(child, params) : null; } } @@ -55,4 +55,4 @@ export function Link({ to, params, ...props }, context) { // commonjs is the real king Views.Views = Views; Views.Link = Link; -export default Views; \ No newline at end of file +export default Views;