react-docgen
react-docgen copied to clipboard
Type annotation with flow syntax and defaulting of args is breaking React Class validator
Hello,
Thanks for your library!
I ran into an issue where a option (flow annotation) argument in a handler was causing my class to not be parsed.. resulting in You have to export at least one valid React Class!. Defaulting the arg also seems to break things.
Breaks:
handleThings = (id: number, active?: boolean) => () => {
things..
}
handleThings = (id: number, active: boolean = false) => () => {
things..
}
Works:
handleThings = (id: number, active: boolean) => () => {
things..
}
Thanks!
Which version of react-docgen are you using?
2.21.0 which I'm now seeing is old. I'm dealing with react-doc-generator which hasn't been updated in a little while.
I've manually upgraded to 3.0.0-rc.0 and I get the same results.
Thanks!
Can you provide a complete example of the file? I tried recreating the issue but when I add any of the methods you provided to to a react class it works fine.
Sorry for the lateness... The following is a full example that gives me the above results if a toggle the handleThings handler.
// @flow
import React from 'react';
export class TestPage extends React.PureComponent {
// Working
handleThings = (id: number, active: boolean) => () => console.log(`handleThings: Works! ${id}, ${active}`);
// No Working
// handleThings = (id: number, active?: boolean) => () => console.log(`handleThings: Works! ${id}, ${active}`);
// handleThings = (id: number, active: boolean = false) => () => console.log(`handleThings: Works! ${id}, ${active}`);
render() {
return (
<button type="button" onClick={this.handleThings(1, true)}>
[Button]
</button>
);
}
}
export default TestPage;
Thanks!
Just a bump here @danez, can I provide more information?