react-dom

Webpack and React — Unexpected token

巧了我就是萌 提交于 2019-11-29 16:23:23
I am new to React and Webpack. I am setting up my first project, when I try to run the webpack-dev-server my code does not compile! Update Answer below is correct. I needed to add 'react' to babel loader presets. You can see the full source for project here: https://github.com/cleechtech/redux-todo Error: $ webpack-dev-server http://localhost:8080/webpack-dev-server/ webpack result is served from / content is served from ./dist Hash: d437a155a1da4cdfeeeb Version: webpack 1.12.14 Time: 5938ms Asset Size Chunks Chunk Names bundle.js 1.51 kB 0 [emitted] main chunk {0} bundle.js (main) 28 bytes

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

别来无恙 提交于 2019-11-29 10:45:25
问题 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

Webpack and React — Unexpected token

这一生的挚爱 提交于 2019-11-28 09:42:31
问题 I am new to React and Webpack. I am setting up my first project, when I try to run the webpack-dev-server my code does not compile! Update Answer below is correct. I needed to add 'react' to babel loader presets. You can see the full source for project here: https://github.com/cleechtech/redux-todo Error: $ webpack-dev-server http://localhost:8080/webpack-dev-server/ webpack result is served from / content is served from ./dist Hash: d437a155a1da4cdfeeeb Version: webpack 1.12.14 Time: 5938ms

ReactJS Module build failed: SyntaxError: Unexpected token - ReactDOM.render

守給你的承諾、 提交于 2019-11-28 06:59:48
问题 Why am I getting this error below? My statement ReactDOM.render(<App />, container); is 100% legit code. My github repo: https://github.com/leongaban/react_starwars The app.js file import react from 'react' import ReactDom from 'react-dom' import App from 'components/App' require('index.html'); // Create app const container = document.getElementById('app-container'); // Render app ReactDOM.render(<App />, container); The components/App file import React from 'react' const App = () => <div

What does registerServiceWorker do in React JS?

假装没事ソ 提交于 2019-11-28 04:27:26
I'm a newbie in React and I was wondering what is the purpose of registerServiceWorker() in the following code? import React from 'react'; import ReactDOM from 'react-dom'; import App from './App'; import registerServiceWorker from './registerServiceWorker'; ReactDOM.render(<App />, document.getElementById('root')); registerServiceWorker(); mostafa tourad The service worker is a web API that helps you cache your assets and other files so that when the user is offline or on slow network, he/she can still see results on the screen, as such, it helps you build a better user experience, that's

When exactly is `componentDidMount` fired?

☆樱花仙子☆ 提交于 2019-11-27 19:41:47
This is a recurring problem I have with React. The componentDidMount method is guaranteed to be fired when the component is rendered for the first time so it seems like a natural place to take DOM measurements like heights and offsets. However, many times I receive wrong style readings at this point of the component's lifecycle. The component is in the DOM, when I break with the debugger, but it's not yet painted on the screen. I get this problem with elements that have width/height set to 100% mostly. When I take measurements in componentDidUpdate - everything works fine, but this method will

React vs ReactDOM?

故事扮演 提交于 2019-11-27 06:08:58
I'm a bit new to react. I see we have to import two things to get started, React and ReactDOM , can anyone explain the difference. I'm reading through the React documentation , but it doesn't say. React and ReactDOM were only recently split into two different libraries. Prior to v0.14, all ReactDOM functionality was part of React. This may be a source of confusion, since any slightly dated documentation won't mention the React / ReactDOM distinction. As the name implies, ReactDOM is the glue between React and the DOM. Often, you will only use it for one single thing: mounting with ReactDOM

What does registerServiceWorker do in React JS?

给你一囗甜甜゛ 提交于 2019-11-27 05:16:02
问题 I'm a newbie in React and I was wondering what is the purpose of registerServiceWorker() in the following code? import React from 'react'; import ReactDOM from 'react-dom'; import App from './App'; import registerServiceWorker from './registerServiceWorker'; ReactDOM.render(<App />, document.getElementById('root')); registerServiceWorker(); 回答1: The service worker is a web API that helps you cache your assets and other files so that when the user is offline or on slow network, he/she can

When exactly is `componentDidMount` fired?

蓝咒 提交于 2019-11-26 16:05:56
问题 This is a recurring problem I have with React. The componentDidMount method is guaranteed to be fired when the component is rendered for the first time so it seems like a natural place to take DOM measurements like heights and offsets. However, many times I receive wrong style readings at this point of the component's lifecycle. The component is in the DOM, when I break with the debugger, but it's not yet painted on the screen. I get this problem with elements that have width/height set to

React vs ReactDOM?

混江龙づ霸主 提交于 2019-11-26 11:54:21
问题 I\'m a bit new to react. I see we have to import two things to get started, React and ReactDOM , can anyone explain the difference. I\'m reading through the React documentation, but it doesn\'t say. 回答1: React and ReactDOM were only recently split into two different libraries. Prior to v0.14, all ReactDOM functionality was part of React. This may be a source of confusion, since any slightly dated documentation won't mention the React / ReactDOM distinction. As the name implies, ReactDOM is