stereobooster / react-snap

👻 Zero-configuration framework-agnostic static prerendering for SPAs
MIT License
5.04k stars 391 forks source link

Client Side Components #487

Closed redxtech closed 3 years ago

redxtech commented 3 years ago

Feature Request

Describe the solution you'd like A way to exclude components/elements from being prerendered. Either a wrapper component to wrap around components that we only want rendered on client side or an attribute/directive that tells react-snap to ignore all the component/element's children. The attribute might be the best way to keep this framework agnostic though.

Describe alternatives you've considered I've tried using vue-client-only but it appears as though the components are still rendered by react-snap.

Teachability, Documentation, Adoption, Migration Strategy Surround the component you want to be client-only with the wrapper component OR add the snap-client-only (for example) diractive/attribute to the component you want to be client-only.

stereobooster commented 3 years ago
const Snap = ({ children }) => {
  const isReactSnap = navigator.userAgent === 'ReactSnap';
  return isReactSnap ? null : children
}
redxtech commented 3 years ago

Perfect, thanks.