Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

关于观察者模式两次弹窗的问题 #312

Open
2943102883 opened this issue Mar 29, 2024 · 0 comments
Open

关于观察者模式两次弹窗的问题 #312

2943102883 opened this issue Mar 29, 2024 · 0 comments

Comments

@2943102883
Copy link

这个是因为在index.js中,外层使用了StrictMode包裹。
在开发模式下,如果使用了严格模式,React会调用两次生命周期。把StrictMode去掉就好了

// index.js
import React, { StrictMode } from 'react';
import { createRoot } from 'react-dom/client';

import App from './App';

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

root.render(<App />);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant