Comments (3)
Hi @Duskfall,
Could you give another try with v0.1.3
?
I've changed one of the components used in tests to be a stateless one:
https://github.com/typicode/react-fake-props/blob/master/fixtures/propTypes/Simple.jsx
It seems to work, let me know if you still have issues.
from react-fake-props.
Thanks @typicode ! It works for simple stateless components now.
There is another test case though which is a more complex one. If we use HOC in a stateless component to encapsulate functionality then it breaks, because fakeProps doesn't find the PropTypes project in the object which is the stateless function at first.
TypeError: Cannot convert undefined or null to object
at Function.keys (<anonymous>)
at fakeDataForProps (node_modules/react-fake-props/lib/index.js:235:17)
at Object.<anonymous>.module.exports (node_modules/react-fake-props/lib/index.js:253:10)
Example component 1 with recompose:
import { compose, withHandlers, withState } from 'recompose';
const WithToggle = compose(
withState('toggledOn', 'toggle', false),
withHandlers({
show: ({ toggle }) => () => toggle(true),
hide: ({ toggle }) => () => toggle(false),
toggle: ({ toggle }) => () => toggle((current) => !current)
})
);
const Simple = WithToggle({ show,hide,toggle}) =><div></div>
Example component 2
export const AnotherHOC = ComposedComponent => class extends React.Component {
constructor(props) {
super(props);
this.state = {
extraStuff: true
};
}
render() {
return <ComposedComponent {...this.props} extraStuff={this.state.extraStuff}/>;
}
};
const Simple = AnotherHOC ({ extraStuff}) =><div></div>
from react-fake-props.
Closing as v0.3.1
should support multiple components in single file and should work better with HOC. Feel free to re-open if needed.
from react-fake-props.
Related Issues (13)
- Why not use propTypes directly? HOT 4
- TypeError: pluginList.indexOf is not a function HOT 4
- Will this work with Typescript? HOT 1
- Try react-docgen-typescript HOT 7
- Usage with connected components (Multiple exported component definitions found) HOT 4
- Nested shape objects HOT 1
- Update react-docgen to 4.0 and add TypeScript tests HOT 4
- Random props
- react-docgen and FlowType support HOT 5
- Generates invalid value for PropType.oneOf (array of strings)
- Fix tests on Node 4
- Immutable types not supported HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-fake-props.