Passing functions as props #921
-
https://fresh.deno.dev/docs/concepts/islands says the following:
In playing around, those claims don't actually appear to be true. Are they outdated? Using
And so does passing functions. Using the same
leads to an
leads to the counter being successfully decremented. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
This is a server side component and you are not passing any functions to the island // index.tsx
export default function Home () {
return <Counter start={3} />
} If you actually pass a funtion from a server side component to an island, it doesn't work. // index.tsx
export default function Home () {
return <Counter fn={() => { }} />
}
// islands/Counter.tsx
export default function Counter ( props: { fn: () => void } ) {
props.fn() // TypeError: props.fn is not a function
return <div></div>
} |
Beta Was this translation helpful? Give feedback.
This is a server side component and you are not passing any functions to the island
Counter
.If you actually pass a funtion from a server side component to an island, it doesn't work.