Can reactJS write into file?

前端 未结 2 1103
名媛妹妹
名媛妹妹 2021-01-11 23:04

As my title says, is it possible? I am begginer at front-end and trying to teach myself reactJS right now. I learned some javascript before and I know it is impossible to re

相关标签:
2条回答
  • 2021-01-11 23:53

    Your question is a bit vague. In addition to what @Stretch0 said, it's possible to read/write files on a user's computer using the browser's native APIs. Here is a good tutorial.

    0 讨论(0)
  • 2021-01-12 00:09

    Well the question is, where does that file live?

    Node is able to write to files because the files exist on the server that node is running on.

    React runs in browser so there is no file system to write to. You can read from a file because the contents of that file get bundled into the Javascript that gets served to the browser.

    If you want to write to a file, you would need to send an API request from your browser / React to a server and have that server write to the file system.

    Additionally, as pointed out by Huy Nguyen, it's possible to write to the clients file system from the browser but that is going to be private to that user.

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