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

Hoist non-react component properties when using withRouter (or any HOC) #12446

Closed
dextermb opened this issue May 3, 2020 · 2 comments
Closed

Comments

@dextermb
Copy link

dextermb commented May 3, 2020

Feature request

Is your feature request related to a problem? Please describe.

I use properties on my components to control the layout in _app.jsx. For example:

const Page = () => (
  <Flex page centered>
    <p>Centered Content</p>
  </Flex>
)

Page.navbar = false

export default Page

But when I need to access the router, I've been using the HOC, with doesn't hoist navbar off the component.

Describe the solution you'd like

I'd like withRouter to hoist non-react component properties. Currently, it only picks out:

It would be a pretty much one-line solution to use hoist-non-react-statics.

Describe alternatives you've considered

I have considered putting them in getInitialProps but I don't this seems like the right place to put them.

Additional context

Add any other context or screenshots about the feature request here.

@timneutkens
Copy link
Member

hoist-non-react-statics is not included by design as it massively increases the router size for very little gain: https://bundlephobia.com/result?p=hoist-non-react-statics@3.3.2

@balazsorban44
Copy link
Member

This issue has been automatically locked due to no recent activity. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

@vercel vercel locked as resolved and limited conversation to collaborators Jan 30, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants