From 80d7415807b9834b72293928c86d1b87c1bafe9c Mon Sep 17 00:00:00 2001 From: Rahul Sharma <31248807+devsmitra@users.noreply.github.com> Date: Tue, 27 Jul 2021 18:26:46 +0530 Subject: Added undefined check for spread props (#832) * husky setup added * pre-commit script updated * Revert "Feat/pre commit" * spread issue fixed #522 * testcase added * spread issue fixed #522 * testcase added --- examples/framework-react/src/components/Counter.jsx | 4 ++-- examples/framework-react/src/pages/index.astro | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) (limited to 'examples/framework-react/src') diff --git a/examples/framework-react/src/components/Counter.jsx b/examples/framework-react/src/components/Counter.jsx index 3ab6728e7..b7b219aae 100644 --- a/examples/framework-react/src/components/Counter.jsx +++ b/examples/framework-react/src/components/Counter.jsx @@ -1,7 +1,7 @@ import React, { useState } from 'react'; -export default function Counter({ children }) { - const [count, setCount] = useState(0); +export default function Counter({ children, count: initialCount }) { + const [count, setCount] = useState(initialCount); const add = () => setCount((i) => i + 1); const subtract = () => setCount((i) => i - 1); diff --git a/examples/framework-react/src/pages/index.astro b/examples/framework-react/src/pages/index.astro index 851eb6e78..79f2ddf74 100644 --- a/examples/framework-react/src/pages/index.astro +++ b/examples/framework-react/src/pages/index.astro @@ -1,7 +1,9 @@ --- // Component Imports import Counter from '../components/Counter.jsx' - +const someProps = { + count: 0, +} // Full Astro Component Syntax: // https://docs.astro.build/core-concepts/astro-components/ @@ -34,7 +36,7 @@ import Counter from '../components/Counter.jsx'
- +

Hello React!

-- cgit v1.2.3