non defined props in functional components are empty
See original GitHub issueVersion
3.2.25
Reproduction link
Steps to reproduce
See reproduction link
What is expected?
Both components Test1
and Test2
behave consistently
What is actually happening?
The Test1 component is written in such a way that the props defined by the generic parameters are missing(BTW my IDE code hints work fine), in fact the option of the component has no props
option, and the additional definition of props
like the following will make it work correctly.
import { defineComponent, ref } from "vue";
const HelloWorld = defineComponent<{ msg: string }>(({ msg }) => {
// some code
});
HelloWorld.props = { msg: { type: String } };
export default HelloWorld;
Does this mean that defineComponent requires adding additional options
such as props
? Or is this a working feature?
I just want to make it easier to use JSX instead of SFC, and more functional, maybe there are some compile-time plugins here that can make this write work for me?
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (4 by maintainers)
Top Results From Across the Web
reactjs - Props are empty on passing them to child class based ...
I can access props by using props.screeningsList and use every value that is inside that prop. Rendering the component is succesfull and I...
Read more >React Functional Components: State, Props, and Lifecycle ...
This is how useEffect works with an empty array, an array with values, or no array. Let's understand how to perform componentWillUnmount with ......
Read more >React Functional Components, Props, and JSX - freeCodeCamp
In this post, you're going to learn some of the basics of React like creating a component, the JSX syntax, and Props. If...
Read more >React Class Components - W3Schools
Before React 16.8, Class components were the only way to track state and lifecycle on a React component. Function components were considered "state-less"....
Read more >Manipulating Arrays and Objects in State with React | Pluralsight
In React, every component can handle its own state. This guide covers how to manipulate state with objects and arrays.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@posva that only applies to functional components, doesn’t it?
Vue requires runtime props options from which prop types are inferred. It’s currently not possible to define a (stateful) component without runtime props and then provide prop types via the generic argument.
I started a discussion some Time ago, @pikax also wrote a small proposal about how to support this in the RFCs repo I think, but so gar it went nowhere.
It’s not a bug, I somehow read a functional component but it’s was a regular one… This is indeed expected for stateful components