react-dom

Should I use ref or findDOMNode to get react root dom node of an element?

感情迁移 提交于 2019-12-03 10:20:20
I'm on a situation where I want to make some dom-node size calculations (top, bottom and size properties of the rendered DOM node) What I'm doing right now, on the componentDidUpdate method is to call findDOMNode on this: componentDidUpdate() { var node = ReactDOM.findDOMNode(this); this.elementBox = node.getBoundingClientRect(); this.elementHeight = node.clientHeight; // Make calculations and stuff } This is working fine, but I'm a bit worried about performance, and react best practices. Several places talks about using ref property instead of findDOMNode, but all of them are for child dom

What's the difference between hydrate() and render() in React 16?

送分小仙女□ 提交于 2019-12-03 04:04:22
问题 I've read the documentation, but I didn't really understand the difference between hydrate() and render() in React 16. I know hydrate() is used to combine SSR and client-side rendering. Can someone explain what is hydrating and then what is the difference in ReactDOM? 回答1: From the ReactDOMServer docs (emphasis mine): If you call ReactDOM.hydrate() on a node that already has this server-rendered markup, React will preserve it and only attach event handlers , allowing you to have a very

react.js : javascript in angle brackets not working

对着背影说爱祢 提交于 2019-12-02 14:58:24
问题 For some reason when I try and enter JavaScript into the angle part of the HTML portion it does not work. I'm using Thymeleaf. Here's the HTML portion: <button className="btn btn-info" onClick={this.displayInfo}>Click for info about {firstName[i]}</button> So in this instance it does not work and returns an error: unexpected error (type=Internal Server Error, status=500) Exception parsing document If I remove the onClick={this.displayInfo} it will work. my function: displayInfo(){ console.log

react.js : javascript in angle brackets not working

久未见 提交于 2019-12-02 12:24:32
For some reason when I try and enter JavaScript into the angle part of the HTML portion it does not work. I'm using Thymeleaf. Here's the HTML portion: <button className="btn btn-info" onClick={this.displayInfo}>Click for info about {firstName[i]}</button> So in this instance it does not work and returns an error: unexpected error (type=Internal Server Error, status=500) Exception parsing document If I remove the onClick={this.displayInfo} it will work. my function: displayInfo(){ console.log("it worked"); } The render() function: render(){ var {number, firstName, lastName} = this.state; var

reactjs; after mapping an array nothing renders

一笑奈何 提交于 2019-12-01 11:48:30
I have an input that after the user inserts a text I want to show each word in a button in button-group . I split the sentence and map it that returns <input .....><button onClick=....> so I insert the text in input, after clicking the button the text.split(" ") everything works correctly till here. but in the button group part shows nothing <div className="btn-group" role="group" aria-label="..."> {this.mapArrayToButtons()} </div> mapArrayToButtons(){ this.state.textArr.map((word)=>{ console.log('the word: ',word); return(<button key={word} type="button" className="btn btn-default" value=

reactjs; after mapping an array nothing renders

我是研究僧i 提交于 2019-12-01 10:30:15
问题 I have an input that after the user inserts a text I want to show each word in a button in button-group . I split the sentence and map it that returns <input .....><button onClick=....> so I insert the text in input, after clicking the button the text.split(" ") everything works correctly till here. but in the button group part shows nothing <div className="btn-group" role="group" aria-label="..."> {this.mapArrayToButtons()} </div> mapArrayToButtons(){ this.state.textArr.map((word)=>{ console

npm ERR! tarball.destroy is not a function

こ雲淡風輕ζ 提交于 2019-11-30 17:06:50
Hi I'm having issue while installing react-dom module. I'm able install other modules like react express modules, on windows 10. 64 bit machine npm install react-dom npm WARN package.json -panel-client@1.0.0 No description npm WARN package.json -panel-client@1.0.0 No repository field. npm WARN package.json -panel-client@1.0.0 No README data npm WARN package.json -panel-client@1.0.0 No license field. npm WARN retry will retry, error on last attempt: Error: EBUSY: resource busy or locked, rename 'C:\Users\NOI-DE~1\AppData\Local\Temp\npm-3064-f12f714d\registry.npmjs.org\react-dom\-\react-dom-0.14

npm ERR! tarball.destroy is not a function

ぃ、小莉子 提交于 2019-11-30 16:27:12
问题 Hi I'm having issue while installing react-dom module. I'm able install other modules like react express modules, on windows 10. 64 bit machine npm install react-dom npm WARN package.json -panel-client@1.0.0 No description npm WARN package.json -panel-client@1.0.0 No repository field. npm WARN package.json -panel-client@1.0.0 No README data npm WARN package.json -panel-client@1.0.0 No license field. npm WARN retry will retry, error on last attempt: Error: EBUSY: resource busy or locked,

Is it ok to use ReactDOMServer.renderToString in the browser in areas where React isn't directly managing the DOM?

浪尽此生 提交于 2019-11-30 07:56:39
I'm working on an app using Leaflet (via react-leaflet ). Leaflet directly manipulates the DOM. The react-leaflet library doesn't change that, it just gives you React components that you can use to control your Leaflet map in a React-friendly way. In this app, I want to use custom map markers that are divs containing a few simple elements. The way to do that in Leaflet is to set your marker's icon property to a DivIcon , in which you can set your custom HTML. You set that inner HTML by setting the DivIcon's html property to a string containing the HTML. In my case, I want that HTML to be

Cannot resolve module 'react-dom'

流过昼夜 提交于 2019-11-30 06:07:26
I've seen few posts related to this type of error. But couldn't resolve in mine. My package.json: "react": "~0.14.7", "webpack": "^1.12.13", "react-hot-loader": "^3.0.0-beta.6", . . I'm getting following error on webpack: ERROR in ./public/src/main.js Module not found: Error: Cannot resolve module 'react-dom' in C:\Users\react-example\public\src @ ./public/src/main.js 19:16-36 But in the cmd line when I did npm -v react-dom I get 3.10.10. react-dom is there. But I wonder why it still gives this error. When I installed react-dom through npm "npm install react-dom", and run webpack I get