rpominov / react-demo

A React-component for creating demos of other components
MIT License
99 stars 9 forks source link

Automatic props #13

Open rpominov opened 9 years ago

rpominov commented 9 years ago

See if we could analyze Target.propTypes so instead of <Demo target={Target} props={...} />, we could do just <Demo target={Target} /> and appropriate controls for props would be chosen automatically.

highruned commented 8 years ago

+1

I feel like I would personally only use react-demo if it did this automatically. Otherwise there's too much overhead in maintaining type for me.

I looked into the React PropTypes and it encapsulates the intended type. I think the only way to get it working would be to iterate the target components proptypes checking against all types to determine which one they used.

I'm willing to help out with this!

Thoughts?

rpominov commented 8 years ago

Yeah, I guess iterate over all React.PropTypes is the only option for us. But a bigger problem is that we won't be able to detect types like React.PropTypes.oneOf(...) because it's just a function created dynamically every time. So this automatic detection will probably work only in simple cases.

cedricdelpoux commented 7 years ago

Any news about that point?