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

SSR not working with Hyperapp #35

Open
talentlessguy opened this issue Dec 30, 2020 · 0 comments
Open

SSR not working with Hyperapp #35

talentlessguy opened this issue Dec 30, 2020 · 0 comments

Comments

@talentlessguy
Copy link

talentlessguy commented Dec 30, 2020

I'm trying to use this library in a server rendered Hyperapp app and I tried this:

// lib/style.ts

import scoped from 'scoped-style'

if (typeof global !== 'undefined') {
  global.scopedStyleCSS == ''
}

const styler = (css: string) => {
  if (typeof document !== 'undefined') {
    scoped.defaultCallback(css)
  } else if (typeof global !== 'undefined') {
    global.scopedStyleCSS += css
  }
}

export const styled = scoped(h, styler)

// pages/index.tsx

import { styled } from '../lib/style'

const Text = styled('p')`
  font-size: 48px;
  font-weight: bold;
`

export default (state: State) => <Text>Hello ${state.text}</Text>

// hyperapp code

which results in this error when trying to build in a browser-less environment:

    return o2.class = t2.join(" ") + " " + (e3.class || e3.className || ""), p.name === "createElementWithValidation" && (o2.className = o2.class, delete o2.class), p(h2, o2, r2);
                                                       ^

TypeError: Cannot read property 'class' of null
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