How to use the effector-react/ssr.serialize function in effector-react

To help you get started, we’ve selected a few effector-react examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github zerobias / effector / examples / react-ssr / src / lambda.ts View on Github external
const routes = Object.keys(users)
    const route = routes[(Math.random() * routes.length) | 0]
    res.setHeader('Location', `/${route}`)
    res.status(302).send('')
    return
  }
  if (!users.hasOwnProperty(url)) {
    res.status(404).send('not found')
    return
  }
  try {
    const scope = await fork(app, {
      start: startServer,
      ctx: users[url],
    })
    const data = serialize(scope)
    const content = renderToString(React.createElement(App, {root: scope}))
    const result = await compile({content, data})
    res.send(result)
  } catch (err) {
    console.error(err)
    res.status(500).send('something going wrong')
  }
}