Skip to content

Does Sandpack offer an option to turn off StrictMode? #704

Answered by rebeccapeltz
rebeccapeltz asked this question in Q&A
Discussion options

You must be logged in to vote

When you create a React App using create-react-app or the codesandbox.io React template it wraps the app in the <StrictMode> component like this

import { StrictMode } from "react";
import { createRoot } from "react-dom/client";

import App from "./App";

const rootElement = document.getElementById("root");
const root = createRoot(rootElement);

root.render(
  <StrictMode>
    <App />
  </StrictMode>
);

StrictMode forces apps in development to render twice looking for side effects https://reactjs.org/docs/strict-mode.html
In my Sandpacks I am rendering images. This is for training. I have some demos where we look at the Chrome network tab to see when an image is rendered. If I'm demoing a…

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@danilowoz
Comment options

Answer selected by rebeccapeltz
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants