score:2
Accepted answer
you can simply use variable as tag (the only requirement is that variable starts with uppercase letter):
render(){
return(
<div>
{this.state.crypto.map(crypto => (
<div>
<h3>{crypto}</h3>
<crypto />
</div>
))}
</div>
)
}
score:1
you can set the name dynamically using react.createelement
function. jsx is just synthetic sugaring over the createelement
function.
render() {
return (
<div>
{this.state.crypto.map(crypto => {
const cryptoelement = react.createelement(crypto)
return <div>
<h3>{crypto}</h3>
{cryptoelement}
</div>
})}
</div>
)
}
fiddle: https://jsfiddle.net/omerts/lagja2sy/
here you can find the documentation about it: https://reactjs.org/docs/react-api.html#createelement
Source: stackoverflow.com
Related Query
- How to set element name dynamically in ReactJS
- Typescript & ReactJS How To Dynamically Set State
- how to get element by component name in ReactJS
- How to dynamically choose which element to render in ReactJS
- How can we remove an element dynamically in Reactjs
- How to set a value to Time Picker dynamically in Reactjs
- How to set a class name for a div dynamically in react js
- How to set CSS in the dynamically add button in Reactjs
- How do I dynamically generate an element with a tag name based on a prop?
- Dynamically applying style to an element which is set with dangerouslySetInnerHTML in reactJS
- How to set dynamically prop to a component in reactjs
- How to set array name in json using reactjs
- How do I dynamically set HTML5 data- attributes using react?
- reactjs - how to set inline style of backgroundcolor?
- How to set activeClassName for wrapper element of Link or IndexLink in react-router?
- ReactJS - How can I set a value for textfield from material-ui?
- How to set HTML lang attribute dynamically on NextJs Document?
- How to set srcObject on audio element with React
- How to set value dynamically inside Form.List using setFieldsValue in Antd 4?
- How can I dynamically load an icon using its snake_case name (React, material-ui)
- React how to dynamically set div height to follow suit of full window height including scroll
- How can I set a CSS name not to be a hash in a Webpack configuration file?
- How to get the ReactJS element inside componentDidMount()?
- How to apply an id attribute to a child element of a ReactJS component?
- How to change the position of the element dynamically in ReactJs?
- ReactJS How To Set Cookie From Fetch Request to Back End
- How to set display name for a React class (ES6)?
- How to set initial tab in react navigation TabNavigator dynamically
- How to dynamically generate pair of input fields using reactjs
- reactjs - how to set style of border?
More Query from same tag
- How to monitor React events while debugging
- How can I execute a query without await in React?
- TypeScript + React: How do I type a component that passes props to an html `img` element?
- Find index in Array of urls
- React - Access a variable declared in componentDidMount() method in render() method
- How to disable browser popup/tooltip when user exceeds max in a number input?
- change api fetch into axios call
- Catch All redux-little-router
- lodash debounce in React functional component not working
- Implement client-side ReactJS permissions or break apps up into multiple files?
- How to use google analytics with next.js app?
- Invalid src prop in Nextjs Image tag
- How to use componentWillMount() in React Hooks?
- What is Prettier keyboard shortcut command in VS Code to format only a block of React code, not just format on file autosave?
- The best way to remove a key from react component's state
- ReactJS - How to allow user to type only integers
- How to test react-dropzone with Jest and react-testing-library?
- React-Router not receiving props if it's the same path, but different param?
- How could I use map to render a list of items but grouped at every 3 items?
- API in nodejs Port Issue
- Populating data on a table in React
- How to set img in label using React?
- How to pass setState to another component
- how to access 1-st payload which was before from(mypromise)
- Running React in Docker using Docker Compose does not work
- Why am I getting an error that a file in Firebase Storage doesn't exist but it actually does when you follow the link?
- Updating Redux store to remove something from array doesn't rerender
- Material ui change color for select box
- How can i pass and display data from one component to other component?
- Reload after deleting user from end of list with React