Save the data in the UI of react in the form of file

Solution 1:

There's no way to automatically download a file and save it in a specific location on your hard disk from a frontend app running inside a browser. The users of your app will decide how the file is saved based on their browser settings.

If you're trying to achieve that kind of thing, then that's wrong and you should consider another approach.

Solution 2:

It's not possible because this poses a security risk.

Most of the OS will defaults the download to download folder.

Pure browser-JavaScript is not be able to get information about the user's filesystem. The default download path might also contain sensible information, which is risky.