Import component in...
Importing a child component is not so different in React, Vue or Svelte. Except when you are using exported component in React with the {}.
Check it out 🚀
React
// top of the file
import { ChildComponent } from 'ChildComponent'
With export default
:
// top of the file
import ChildComponent from 'ChildComponent'
Vue
<script setup lang="ts">
import ChildComponent from 'ChildComponent.vue'
</script>
Svelte
<script lang="ts">
import ChildComponent from 'ChildComponent.svelte'
</script>
Passing props
in...
React and Svelte has the same approach. Vue, on other hand, has the v-bind directive or its shorthand.
Check it out 🚀
React
<ChildComponent msg={msg} />
Vue
<ChildComponent v-bind:msg={msg} />
// or shorthand
<ChildComponent :msg={msg} />
Svelte
<ChildComponent msg={msg} />
Top comments (0)