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

withHydrationOnDemand add tag section #32

Open
tavakai opened this issue Apr 18, 2023 · 0 comments
Open

withHydrationOnDemand add tag section #32

tavakai opened this issue Apr 18, 2023 · 0 comments

Comments

@tavakai
Copy link

tavakai commented Apr 18, 2023

I'm trying to use react-hydration-on-demand to load components on demand, but it seems to be adding an additional section wrapper around my component. I've tried setting the wrapper option to false in the withHydrationOnDemand HOC, but that doesn't seem to be working.

Here's an example of my withCustomWrapper HOC:

import withHydrationOnDemand from 'react-hydration-on-demand'

const MyCustomWrapper = ({ children }) => <>{children}</>

const withCustomWrapper = (Component, on = ['visible']) => {
  const WrappedComponent = withHydrationOnDemand({ on, onBefore: Component.preload, wrapper: false })(Component)
  return props => <MyCustomWrapper><WrappedComponent {...props} /></MyCustomWrapper>
}

export default withCustomWrapper
const ImageLazy = LoadableVisibility({ loader: () => import(/* webpackChunkName: "Image" */ './Image'), loading, wrapper: false })
const Image = withCustomWrapper(ImageLazy)

However, the resulting markup for the LazyImage component is:

<section>
  <img src="https://example.com/image.jpg" />
</section>

Is there any way to use react-hydration-on-demand without adding this additional section wrapper?

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

1 participant