Skip to content
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

Connector API to access isPending #11

Open
SamyPesse opened this issue Jan 15, 2018 · 1 comment
Open

Connector API to access isPending #11

SamyPesse opened this issue Jan 15, 2018 · 1 comment

Comments

@SamyPesse
Copy link

I'm starting to use react-skeletor, and I'm missing something in the API: a connector to access the isPending and have my own logic of rendering, for example a component to render an avatar:

import { connectSkeleton } from '@trainline/react-skeletor';

@connectSkeleton(({ isPending }) => ({
    isPending
})
class Avatar extends React.Component {
    render() {
         const { isPending } = this.props;

         return isPending ? <div></div> : <a href="...">...</a>
    }
}

Currently, I can directly use contextTypes and get the skeleton context, but this is a not recommended API by React.

At some point, it may requires a subscribing schema in the context instead of storing the values directly.

Will you be willing to accept a connectSkeleton API ? (I can make a PR)

@alex3165
Copy link
Contributor

Hi @SamyPesse, glad to hear you are using react-skeletor. I think you can write your own HOC and access the context, that is what a connectSkeleton HOC would do anyway. React forbid the use of context if you don't really know what you are doing and think of using context to replace props which is wrong in 90% of the cases.

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

2 participants