Warning: findDOMNode is deprecated in StrictMode. findDOMNode was passed an instance of Transition which is inside StrictMode
The setState call looks like it’s being written to the wrong place. Make sure it’s on the editTodo object:
The setState call looks like it’s being written to the wrong place. Make sure it’s on the editTodo object:
You are passing hello() as a string, also hello() means execute hello immediately. try
Try this, which is way cleaner too: Get that switch out of the render in a function and just call it passing the params you want. For example:
I suspect that the problem lies in the fact that you are calling your state setter immediately inside the function component body, which forces React to re-invoke your function again, with the same props, which ends up calling the state setter again, which triggers React to call your function again…. and so on. Instead, I … Read more
Also using Babel, Typescript and Jest. Had the same failure, driving me crazy for hours. Ended up creating a new babel.config.js file specifically for the tests. Had a large .babelrc that wasn’t getting picked up by jest no matter what i did to it. Main app still uses the .babelrc as this overrides babel.config.js files. Install jest, ts-jest and babel-jest: babel.config.js (only used by … Read more
I use classnames when there is a fair amount of logic required for deciding the classes to (not) use. An overly simple example: That said, if you don’t want to include a dependency then there are better answers below.
Class Names Firstly, if you’re certain that you’re extending from the correctly named class, e.g. React.Component, not React.component or React.createComponent, you may need to upgrade your React version. See answers below for more information on the classes to extend from. Upgrade React React has only supported ES6-style classes since version 0.13.0 (see their official blog post … Read more
Export like export default HelloWorld; and import, such as import React from ‘react’ are part of the ES6 modules system. A module is a self contained unit that can expose assets to other modules using export, and acquire assets from other modules using import. In your code: In ES6 there are two kinds of exports: Named exports – for example export function func() {} is a named … Read more
You can use useEffect/useLayoutEffect to achieve this: More about it over here. If you are looking for an out of the box solution, check out this custom hook that works like useState but accepts as second parameter a callback function:
You can use useEffect/useLayoutEffect to achieve this: More about it over here. If you are looking for an out of the box solution, check out this custom hook that works like useState but accepts as second parameter a callback function: