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
)
Source: stackoverflow.com
Related Query
- XML sitemap for react app
- Info.plist file for react native ios app using expo SDK
- "Failed to load resource: net::ERR_HTTP2_PROTOCOL_ERROR" for React app after upgrading to Visual Studio 2019 16.10.0
- How to set headers for a React app created using 'create-react-app'
- How do I configure my .htaccess file for React App in Subdirectory?
- Simple password-protection for React app on Heroku
- Disable Debugging in Expo For React Native App
- How to change default localhost port for React App
- App Engine app.yaml handlers for built React app
- React app is looking for static files in different location when using proxy
- How to change PublicPath for Create React App in Dev Environment
- How to implement a React infinite scroll component for a chat app like Facebook Messenger?
- Using Jquery and Bootstrap with Es6 Import for React App
- How to Fix Heroku Application Error For a Successfully Deployed React App
- Set up proxy server for create react app
- Developing a Redux store as a seperate NPM module for a React App
- Expo QR code not showing for a React Native App
- Creating Custom UI component for android on React Native fails. App crashes
- React app build failed for popper js typescript error
- Can't find variable: _d when running react native app for the first time
- Creating an installer for Electron React JS app - reactJS component doesn't load when run after install
- How to use Turborepo for an existing react app created with Create React App in order to make it a monorepo?
- React App - Include /health - Health Endpoint for Load Balancer
- Turn off autoComplete for all inputs in React app
- Universal rendering for react app based on create-react-app
- React Native: App Store Rejection, Support for IPv6
- How can I programmatically set the user details for Launch Darkly in my react app
- Create React App for multiple apps?
- How to apply react-native-linear-gradient for the entire app background with React Native
- setup localStorage for testing React app with jest
More Query from same tag
- initialise react component with props and return as html string
- React Onclick display parent array
- browserify bundle doesn't handle importing files via relative path
- not a function with react
- From a Flux component function, how to access an input's value?
- How to get data from my axios request without using a setTimeout?
- TypeScript Theme Switch types erros
- How to import SVG into Next.js component?
- React HOC throws React.createElement: type is invalid
- react.js posting string or json through exception
- onChange input in react-hook-form
- Need help to call an action using redux as well as update Component State on a single event of Click?
- Fetching from Redux-Toolkit store returns undefined
- How to filter an array with fetched data in React.js?
- Error: Cannot 'file' or 'directory' ./lib/React when using with webpack
- using dotenv with react & webpack
- ReactJS onClick ReactCSSTransitionGroup animation
- not getting string from the firebase database
- Microsoft Graph Toolkit: get logged in user
- how do start cron in nextjs after server restart , we not using custom server
- subjects.map is not a function error when updating state when using array of objects
- material-ui card with openlayers map inside?
- How to solve "Unsupported platform for inotify@1.4.2"
- Map over two arrays and display data in a single table?
- ReactJS - setting an inline style equal to a property on state is not working. What's going on?
- How do I un-render a component after routing it to another component in ReactJS?
- How to change the Icon when clicking on it in react
- React-Select, adding copy paste feature to multi select text input
- What is the best way to stop the date updating in react?
- Show search result component in another route