Questions tagged [react-strictmode]
26 questions
                    
                    209
                    
            votes
                
                6 answers
            
        My React Component is rendering twice because of Strict Mode
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 the strict mode? Can I…
         
    
    
        Marry Joanna
        
- 2,103
- 2
- 6
- 5
                    156
                    
            votes
                
                13 answers
            
        Warning: findDOMNode is deprecated in StrictMode. findDOMNode was passed an instance of Transition which is inside StrictMode
I am trying to use a function as a prop inside a component and this component is a child of another component. But the function is not working.? Can I know why. This is the warning i am receiving in the console.
Warning: findDOMNode is deprecated…
         
    
    
        Niroshan_Krish
        
- 1,622
- 2
- 7
- 11
                    90
                    
            votes
                
                4 answers
            
        What is StrictMode in React?
I heard that strict mode helps to write React code in best practices way by throwing warnings for life cycle methods removal. I read about it from this article on Medium.
Is my understanding correct? How effective is strict mode? Is it only for…
         
    
    
        Hemadri Dasari
        
- 32,666
- 37
- 119
- 162
                    24
                    
            votes
                
                1 answer
            
        findDOMNode is deprecated in StrictMode. findDOMNode was passed an instance of DraggableCore which is inside StrictMode
Draggable package is causing an error in strict mode:
Warning: findDOMNode is deprecated in StrictMode. findDOMNode was
passed an instance of DraggableCore which is inside StrictMode.
Instead, add a ref directly to the element you want to…
         
    
    
        Francesco Orsi
        
- 1,739
- 4
- 16
- 32
                    19
                    
            votes
                
                6 answers
            
        React 18 strict mode causing component to render twice
The changes to strict-mode in React version 18 causes my code to render twice, which causes an error in axios abort controller, but I don't know how to clear the error from the browser console after the app renders twice.
Please note: I am working…
         
    
    
        neil
        
- 353
- 1
- 8
- 17
                    17
                    
            votes
                
                4 answers
            
        How to disable react strict mode on third party libraries
We use strict mode in our React app. But third parties does not use strict mode. How can I achieve this?
         
    
    
        babbego
        
- 171
- 1
- 3
                    16
                    
            votes
                
                3 answers
            
        React / Reactstrap Warning: Legacy context API has been detected within a strict-mode tree
This is brand new install - I have not put any transitions on the Alert component
To replicate the code it is simple
import React from "react";
import { Alert } from "reactstrap";
export const Index = () => {
   return (
      
         
        
            
            
                
                    
    
    
         
    
    
                
            
        
     
                     
    
    
        Michael Nelles
        
- 5,426
- 8
- 41
- 57
                    11
                    
            votes
                
                2 answers
            
        How to disable Strict Mode in React 18?
Simply, how can I disable Strict Mode in React 18? I'm using React 18 with create-react-app.
        user20779272
                    10
                    
            votes
                
                1 answer
            
        Is there a way to check if React's `StrictMode` is on?
Is there a way in React -- either in code or via the React devtools -- to see if a component is being rendered in React's StrictMode? In my dream world, there would be some kind of constant I could console.log, say a bool of…
         
    
    
        Erdős-Bacon
        
- 748
- 8
- 16
                    10
                    
            votes
                
                2 answers
            
        Does strict mode work differently with React 18?
Consider the snippets below. With React 18, count gets printed twice to the console on every render but with React 17 it gets printed only once.
React 18 Example:
function App() {
  const [count, setCount] = React.useState(0);
 …
         
    
    
        Developer
        
- 425
- 3
- 15
                    9
                    
            votes
                
                3 answers
            
        Is it safe to change a ref's value during render instead of in useEffect?
I'm using useRef to hold the latest value of a prop so that I can access it later in an asynchronously-invoked callback (such as an onClick handler). I'm using a ref instead of putting value in the useCallback dependencies list because I expect the…
         
    
    
        jtbandes
        
- 115,675
- 35
- 233
- 266
                    7
                    
            votes
                
                2 answers
            
        Can I keep  in my app but make it not render twice 
        I have my app inside a Strict Mode and it makes it difficult to run with my useEffect().
It basically logs all my values twice in the console which is not the result I want to achieve.
 useEffect(() => {
console.log('logs some data')
}, []);
It…
         
    
    
        Metgher Andrei
        
- 197
- 1
- 10
                    7
                    
            votes
                
                1 answer
            
        Should I use React.StrictMode in my test suite?
First time posting a question :)
I have a React application with:
// index.js
ReactDOM.render(
  
    
       
   ,
  document.getElementById('root'),
);
I have 24 jest test suites,…
         
    
    
        Willow
        
- 1,132
- 5
- 20
                    5
                    
            votes
                
                1 answer
            
        React 18 StrictMode first useEffect wrong state
another React 18 strict mode question. I'm aware React will call the render and effect functions twice to highlight potential memory leaks with the upcoming features. What I yet don't understand is how to properly handle that. My issue is that I…
         
    
    
        fragsalat
        
- 500
- 4
- 14
                    3
                    
            votes
                
                1 answer
            
        Should I manualy disable React StrictMode in production?
I was reading the doc and learned that React StrictMode is for development only, and it explains why we have double invoke.
That's great, but does it mean I have to disable the StrictMode manualy for my production, or does react build command does…
         
    
    
        Johan
        
- 2,088
- 2
- 9
- 37