react-dom

My React Component is rendering twice because of Strict Mode

岁酱吖の 提交于 2020-06-25 02:11:08
问题 My React Component is rendering twice. So, I decided to do a line by line debug and the problem is here if ( workInProgress.mode & StrictMode) { instance.render(); } React-dom.development.js Is it because of strict mode? can I disable it? What is Strict mode? Do I need it? 回答1: StrictMode renders components twice (on dev but not production) in order to detect any problems with your code and warn you about them (which can be quite useful). If you have StrictMode enabled in your app but don't

How react-dom identify the correct HTML file?

与世无争的帅哥 提交于 2020-06-23 07:11:18
问题 I am trying React with codesandbox.io. When a new project is started, a default code is displayed. In the index.js file, we have a reference to the "root" element in the HTML file. But I did not realize how the JS file is connected to the HTML file. In Vanilla JS, the HTML file could have an "script" tag. Why a "script" tag is not necessary here? Code index.js import React from "react"; import ReactDOM from "react-dom"; import "./styles.css"; function App() { return ( <div className="App">

How to determine when mobx computed variable is called.?

倾然丶 夕夏残阳落幕 提交于 2020-05-28 04:45:26
问题 I have been playing with mobx computed, but I am having trouble understanding what is happening with the following code: import React, { Component } from "react"; import { render } from "react-dom"; import { observable, computed } from "mobx"; import { observer } from "mobx-react"; @observer class Counter extends Component { @observable count = 0; @observable secondCount = 0; @computed get countString() { console.log("countString Computed"); return `${this.count} ${this.secondCount}`; }

TypeScript and ReactDOM.render method doesn't accept component

守給你的承諾、 提交于 2020-05-25 17:06:28
问题 TL;DR I'm using TypeScript and React. I've defined my AppContainer.tsx component, exported it as default. I'm consuming this in the file app.ts where ReactDOM lives to render it to the targetted dom element. But there I receive the following errors (see image). Read below for more information and links to GitHub repo. Question: What am I doing, or interpreting, wrong? From all code examples I've seen this should work - but maybe (clearly) I'm missing something. Below is more info and links to

TypeScript and ReactDOM.render method doesn't accept component

非 Y 不嫁゛ 提交于 2020-05-25 17:05:59
问题 TL;DR I'm using TypeScript and React. I've defined my AppContainer.tsx component, exported it as default. I'm consuming this in the file app.ts where ReactDOM lives to render it to the targetted dom element. But there I receive the following errors (see image). Read below for more information and links to GitHub repo. Question: What am I doing, or interpreting, wrong? From all code examples I've seen this should work - but maybe (clearly) I'm missing something. Below is more info and links to

TypeScript and ReactDOM.render method doesn't accept component

↘锁芯ラ 提交于 2020-05-25 17:05:35
问题 TL;DR I'm using TypeScript and React. I've defined my AppContainer.tsx component, exported it as default. I'm consuming this in the file app.ts where ReactDOM lives to render it to the targetted dom element. But there I receive the following errors (see image). Read below for more information and links to GitHub repo. Question: What am I doing, or interpreting, wrong? From all code examples I've seen this should work - but maybe (clearly) I'm missing something. Below is more info and links to

`requestAnimationFrame` polyfill error in Jest tests

一个人想着一个人 提交于 2020-05-25 09:03:49
问题 Got this error after upgrading to React when I ran my Jest unit tests: React depends on requestAnimationFrame. Make sure that you load a polyfill in older browsers. How do I fix it? I'm using Jest 18.1.0. 回答1: Found a workaround! Steps: Create the file __mocks__/react.js Add the following into __mocks__/react.js const react = require('react'); // Resolution for requestAnimationFrame not supported in jest error : // https://github.com/facebook/react/issues/9102#issuecomment-283873039 global

`requestAnimationFrame` polyfill error in Jest tests

為{幸葍}努か 提交于 2020-05-25 09:03:31
问题 Got this error after upgrading to React when I ran my Jest unit tests: React depends on requestAnimationFrame. Make sure that you load a polyfill in older browsers. How do I fix it? I'm using Jest 18.1.0. 回答1: Found a workaround! Steps: Create the file __mocks__/react.js Add the following into __mocks__/react.js const react = require('react'); // Resolution for requestAnimationFrame not supported in jest error : // https://github.com/facebook/react/issues/9102#issuecomment-283873039 global

`requestAnimationFrame` polyfill error in Jest tests

别来无恙 提交于 2020-05-25 09:03:09
问题 Got this error after upgrading to React when I ran my Jest unit tests: React depends on requestAnimationFrame. Make sure that you load a polyfill in older browsers. How do I fix it? I'm using Jest 18.1.0. 回答1: Found a workaround! Steps: Create the file __mocks__/react.js Add the following into __mocks__/react.js const react = require('react'); // Resolution for requestAnimationFrame not supported in jest error : // https://github.com/facebook/react/issues/9102#issuecomment-283873039 global

Since updating react-dom and react-router-dom packages: excessive li onClick behavior

白昼怎懂夜的黑 提交于 2020-03-25 19:20:34
问题 I've inherited a react/node/prismic application where we need to update the prismic-reactjs package, which resulted in needing to update a few others- in total, we changed: prismic-reactjs: 0.2.0 → 1.1.0 react: 15.6.1 → 16.0.0 webpack: 3.12.0 → 4.39.2 react-dom: 15.6.1 → 16.0.0 react-router-dom: 4.1.2 → 5.0.1 extract-text-webpack-plugin (deprecated) → mini-css-extract-plugin Then removed one use of "withRouter()" because of new error when starting up the local server (but I confirmed in