Props auto complete does not support function component
See original GitHub issueThanks for this great project!
I’m trying to apply playroom our own component library which is fully written in Typescript. Just notice that for Class component the props auto complete(popup in editor) works very well, but for functional component, it can render the component in UI, but no props popup.
I assume playroom use react-docgen-typescript
to extract props definition from typescript files, I found an example in react-docgen-typescript
’s Readme file:
import * as React from 'react';
/**
* Grid properties.
*/
export interface GridProps {
/** prop1 description */
prop1?: string;
/** prop2 description */
prop2: number;
/**
* prop3 description
*/
prop3: () => void;
/** Working grid description */
prop4: 'option1' | 'option2' | 'option3';
}
/**
* Form Grid.
*/
export const Grid = (props: GridProps) => {
return <div>Grid</div>;
};
There is no props popup for this component in UI.
Issue Analytics
- State:
- Created 3 years ago
- Comments:10 (5 by maintainers)
Top Results From Across the Web
"Access component props" autocomplete works wrong with ...
Start typing console.log(pro and select first autocomplete variant. What is the expected result? console.log(props);. What happens instead?
Read more >React JS auto complete functions - Stack Overflow
I am creating a reactJS webapp that has many different functional components, each functional component has some props and it is hard to ......
Read more >React props auto-complete in VS Code - DEV Community
Unfortunately, when it comes to React components, autocomplete doesn't work as well as vanilla JavaScript : By default when writing props ...
Read more >Using Autocomplete with React - Algolia
This guide shows how to create a React Autocomplete component. It uses the useRef and useEffect hooks to create and mount the component....
Read more >Using JSDoc to enable intellisense for render props in vscode
For function components, vscode can offer code completion ... vscode does not provide any autocompletion when adding props in the usage ...
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 FreeTop 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
Top GitHub Comments
OK, I teased apart my own issue at least so posting back. Hopefully not too tangential/noisy from the OP.
When I publish my component library and deploy it’s accompanying docs website I also build a copy of playroom, etc. This works fine. All my props are autocompleted, both keys and values. All of my components export an interface… causing this to all work out-of-the box.
The problem I’m having is that I have another instance of playroom where I import components from 3rd party libraries as well as my own component library. Here autocompletion doesn’t work. This is all explained by the fact that
react-docgen-typescript
doesn’t support reading types fromd.ts
files. My component library exports types from the componenttsx
files but when I build it those are transpiled away andd.ts
files are created (new to TS but assume this is typical).I think it’d be best if playroom config took an option e.g.
staticTypes
that it would use if present rather than callinglib/getStaticTypes
(see https://github.com/seek-oss/playroom/blob/master/lib/getStaticTypes.js).I was able to generate the correct types pretty easily for my library, just need a way to load them. Would it be worthwhile to submit a patch? Happy to work on it.
Example of using
getStaticTypes
externally:Upgraded to use the latest docgen versions as part of #232, and functional components seem to be working.
Closed by #232