Using React with ejs?

前端 未结 1 918
你的背包
你的背包 2021-02-10 01:55

I have a front-end that is built using React states that is meant to adapt based on user action. However, my front-end React is also meant to show and allow manipulation of my s

相关标签:
1条回答
  • 2021-02-10 02:17

    In express:

    res.render('view', {user: myUser});
    

    In EJS before the app's js bundle:

    <script type='text/javascript'>
      var userFromServer =<%-JSON.stringify(user)%>
    </script>
    

    Use userFromServer in your react code.

    0 讨论(0)
提交回复
热议问题