Skip to content

As HOC #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
srph opened this issue Nov 24, 2015 · 3 comments
Open

As HOC #1

srph opened this issue Nov 24, 2015 · 3 comments

Comments

@srph
Copy link

srph commented Nov 24, 2015

@window
export default MyComponent

What do you think?

@balupton
Copy link

I think using decorators like:

@windowResize
class MyComponent extends Component {
    onWindowResize ({windowHeight, windowWidth}) {
        this.setState({
            fontSize: windowHeight > windowWidth ? '50vw' : '50vh'
        })
    }
    // ...
}

Would be a nice touch, as the component way feels a bit strange.

Example usage of the decorator patten in another library I use:

@Keydown
class MyComponent extends Component {
    componentWillReceiveProps ({keydown}) {
        if ( keydown.event ) {
            // ...
        }
    }
    // ...
}

@kunokdev
Copy link

@balupton @srph Guys, I am still using logic from this library, but due to deprecation warnings and inactivity I had to rewrite it. I customized it to add support for rendering children and as HOC using basic syntax. I would be interested to implement what you proposed if you would share more info. Here is source code: https://github.com/kunokdev/react-window-size-listener/blob/master/src/index.js

@balupton
Copy link

I switched to Mithril from React so can no longer offer feedback

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants