score:1
you can try to use render
props to the route
component:
<switch>
{this.props.admin.map((item, index) =>
<route
path={item.path}
exact
key={item.id || index} // add new id to the data itself
render={() => item.component}
/>
)}
</switch>
the reason is, by this documentation, component
props can only accept a react component, not inline jsx. but you can use render
to generate an inline jsx dynamically.
Source: stackoverflow.com
Related Query
- How dynamically add route to the react app?
- How to add new props dynamically to the component using navigator in React Native
- How to add build react app (js,css) in to the laravel back end server
- How to add another route to the default react application made with create-react-app?
- How do you add an keyup event listener to window in a React functional component that only gets added when the app originally loads?
- how to dynamically change the message in popup in React App
- How to add the GoogleChromeLabs input-first-delay polyfill to a React app
- Im building a React App that requires a pdf to download, in the event the (materialUI) download button is clicked, how can I add that functionality?
- How to programmatically add a className and a onLoad function to all the images in the project at once in React app without Jqyery
- How to add dynamically property for the parameter of React setState method
- How to add dynamic header to the request send from react app
- How to create a React app directly in the current folder
- How to set the DefaultRoute to another Route in React Router
- How to show a loading indicator in React Redux app while fetching the data?
- How do I add validation to the form in my React component?
- How to add "refs" dynamically with react hooks?
- How to detect the device on React SSR App with Next.js?
- How to pass the match when using render in Route component from react router (v4)
- How to load the google maps api <script> in my react app only when it is required?
- How to compress the files using gzip in react app
- How do I add an item to the front of a state array in React
- How to handle exit app in one screen not in the whole app - React Native?
- React Typescript - How add Types to location.state when passed in a Route
- How do I add the Intercom script in my React app?
- How to add a button inside a cell in the DevExtreme React Grid?
- How to add components to list dynamically in React with no redundant render?
- How to change the domain name on a local deployed React app
- how to pass props to the route when using react router <Link>
- How to route in electron react app during production
- How do you dynamically insert a React component into the DOM (for instance a dialog)?
More Query from same tag
- How to set the selected state of Select2 component in React?
- ReactJs rendering a nested value in an array of objects
- Node app fails with SyntaxError: Unexpected token '...'
- Passing a value to a function within React map function
- InnerBlocks with template returning a block count of zero
- Set Variable to Child Node in React
- how to deploy next js app without vercel to custom server using ftp server like filezilla
- Webpack HMR not reloading imported TypeScript modules
- Can I make something exactly the same as <input checked={this.state.foo === "foo"} /> with <button /> ? ReactJS
- App keeps re-rendering when setting state in promise using useState in React
- String useState Value Is Empty after Storing a Value in an API Response to It
- Unable to update JSX attribute based on URL parameter in a Gatsby app running in production
- React-Redux not dispatching action type
- React get Array from external .js that loaded async
- Passing props to parent
- Representing "logged in" and "logged out" in Redux & Typescript to avoid excessive checks in mapStateToProps
- Make api requests work from another computer on the same network in a react app
- How to load an image from a json response field in reactjs
- Can't use createRef in latest version of create-react-app
- Why is my local state being overridden? React
- Convert jsx to react component?
- What is dispatcherIndex used for in React TODO example
- How to set target in typescript to fromEvent() in rxjs
- How to extract some data from json in react JS (axios)?
- Avoid having to specify a key for list of very simple elements
- how to calculate the value from one input without eval() in react
- prompt(), but made in React
- Access child state of child from parent component in react
- findDOMNode() and getDOMNode() are not a functions
- How to add inline legends to line / area mixed chart in highchart