Skip to content

Is there a way to share state between the server and the client? #1

Description

@sebastianmacias

For instance in a react/redux serverside rendered application you can pass the state to the client like this:

ie:

import { renderToString } from 'react-dom/server'

function handleRender(req, res) {
  // Create a new Redux store instance
  const store = createStore(counterApp)

  // Render the component to a string
  const html = renderToString(
    <Provider store={store}>
      <App />
    </Provider>
  )

  // Grab the initial state from our Redux store
  const preloadedState = store.getState()

  // Send the rendered page back to the client
  res.send(renderFullPage(html, preloadedState))
}

taken from: http://redux.js.org/docs/recipes/ServerRendering.html

An example that shows how to achieve the equivalent in marko would be very helpful.

I'm just starting to explore marko, amazing stuff so far, congrats

I'm trying to figure out how all the pieces would fit together to build single page isomorphic apps, kind of like what Nuxt does

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions