Skip to content

Async rendering on the server? #143

Discussion options

You must be logged in to vote

deeply nested so this is not really an option

You can easily send data deeply down:

// import _state from somewhere from nano-jsx
import { _state } from '../state.js'

const getData = () => new Promise(resolve => setTimeout(() => resolve('hello'), 1000))

class App extends Component {
  render() {
    return (
      <ul>
        <li>Nano JSX App</li>
        <li>second</li>
        <li>{_state.get('some-unique-key')}</li>
      </ul>
    )
  }
}

const main = async () => {
  const data = await getData()
  const app = renderSSR(() => {
    _state.set('some-unique-key', data)
    return <App />
  })
  console.log(app)
}
main()

I’ve read somewhere in issues that you experimented with asyn…

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
1 reply
@bitkidd
Comment options

Comment options

You must be logged in to vote
0 replies
Answer selected by bitkidd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants