score:0

A simple solution would be to add <a href="XML_PATH" style={{display:"none"}}>xml</a> Then check your google chrome development console, search for the anchor(a) tag. And follow the path

score:1

In , keyword component should be a React Component.

Check the documentation´╝ÜRoute - React Router


If you want to pass XML as a variable, you should change XML format to string and with another prop but component={}.To transform XML to String, ry escape(XML) before passing to Route! Check escape(str)


with import keyword, youcan try like this:

// file: get-xml.js
let transformXMLToString = () => {

  // read the target XML fiel and transform it to String
  
  // return the string
  return XMLasString;
};

export transformXMLToString;

// then you could import the XML like this in another file:

import transformXMLToString from 'get-xml.js';

// then pass it to <Route> like:

<Route component={transformXMLToString()}/>

score:7

If you are using create-react-app, just put your XML file in public folder (a folder beside node_modules and src folders), then access it through {base_url}/{XML_file_name.xml} (e.g. localhost:3000/sitemap.xml)


Related Query

More Query from same tag