Git Product home page Git Product logo

Comments (3)

typicode avatar typicode commented on May 18, 2024

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.

Duskfall avatar Duskfall commented on May 18, 2024

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.

typicode avatar typicode commented on May 18, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.