score:1
Accepted answer
The issue seems to be in the map function. You are not returning anything from the function.
Return properly and it should work fine.
{this.state.boxes.map((box,index)=>{
return ReactDOM.createPortal( //Return here
box,
document.getElementById("portal"+(this.state.boxes.length-index).toString())
)
)}
Hope it helps. Revert for any doubts/clarifications.
Source: stackoverflow.com
Related Query
- Can I port an element to any DOM node using react portals?
- How can i create a new element and add onclick attribute to it using dom Manipulation in react
- Getting DOM node from React child element
- how to check the actual DOM node using react enzyme
- Can I use an HTML5 audio element to play a sound file in a functional component using React Hooks?
- React and using ReactDOM.createPortal() - Target container is not a DOM element Error
- React failing to update DOM after a element was moved using javaScript from another library
- Target container is not a DOM element using webpack 4 and React
- Can I create a React Element from an HTML string or dom node/element
- Can I use mock data and proxy api data at the same time in my react project when using node express as a proxy server?
- Is there any way i can trigger the onEnded attribute on the video element while testing using jest?
- React - How to notify popper to reposition my popover whenever react updates any DOM element
- How can I access existing dom elements when using react render?
- How to get an element height in react js with out using any pulgin
- How can I add onClick event for Ref Element using React Hooks?
- Target and hide element in the DOM using react
- I'm using react-slick, how can I export a React Component as a single element but remove the parent div on render
- How to get the ref.current dom element when using react-select and react refs?
- How to find out if element in react have onClick event using dom
- How to overriding css by using dom element in react
- In React ES6, is there any benefit to using an imported component that contains only one element tag with a class?
- Using methods of react component in native dom element
- How to I access DOM element using 'this' keyword in React
- How to access more than one element of Dom in react using React.createRef()
- Using roles and specific user id to limit what sections can be viewed in react / node / express / mysql?
- How to get exact DOM element using useRef in React
- Is there any way to define an element in React that can be used throughout the component?
- How we can give type to react element using TSX
- Using SCSS, How can I give CSS style to a specific element among the elements with the same node position?
- How can I add an element to a list with a key value using a useState Record type in React typescript?
More Query from same tag
- Unable to mount the component in react class based components
- invariant violation, invalid hook call, useApolloClient
- Avoid loading data passed as props with React Router
- React, call a stateless function to organize code, but how to bind this?
- Configuring webpack to work with TypeScript using Babel
- React Native - Manage CheckBox states
- Not able to display data string from api with REACT-wysiwyg
- React input doesn't type
- ReactJS giving inst.render is not a function error
- How to append array of objects through form data in Javascript
- React.js: Get values as string from a state array
- ReactJS change value of nested state
- React - how to render a map of field arrays (multiple responses to a single form question)
- The 'componentDidMount' lifecycle method does not update the state
- HTTP request received with status 200 and without body
- How to handle data display with multiple checkboxes in React Js
- React components library rendering React Links
- How can I render Parent component again after update from the child component
- addEventListener is null in React
- React-Table: exception thrown calling 'getResolvedState()' on component ref
- How to reset value on form field?
- How do I redirect a user to another page when a countdown timer gets to 0?
- babel-loader jsx SyntaxError: Unexpected token
- React UseContext with useReducer re-renders the whole app even after splitting
- Scroll to a component when a button is clicked in React JSX
- How to not mutate a prop variable used as state in a React component without a dummy variable?
- Page refresh break styles on Nextjs production app
- react-router cannot read location of undefined
- React.js remove item from Array in state syntax
- How to set color of existing css class, from props of a react component