English 中文(简体)
for deletefor deletefor deletefor deletefor delete [duplicate]
原标题:
  • 时间:2022-04-04 10:06:59
  •  标签:
  • sdf

dssddssddssddssddssddssddssddssddssddssddssddssddssddssddssddssddssddssddssddssddssddssd

问题回答

Are you using a <StrictMode>? If yes, then Strict mode has been designed to run effects twice.

Strict mode is for detecting bugs you may have inside your effects but also for detecting other issues with your code that would prevent you to easily upgrade to the next version of React. Your effects should be resilient to it, calling them twice should not cause bugs in your code, even it means your API is called twice. In production, it doesn t do anything, it s a development only tool.

In this case, it s trying to point out you have an issue in your effect that it doesn t have a cleanup phase for example. If the effect has been cleaned up because the dependencies changed or because the component unmounted, you would have an issue (like calling setState on an unmounted component).

Example of cleanup:

useEffect(() => {
  // use local flag
  let cleanup = false

  const process = () => {
    Promise.resolve(true).then(() => {
      // check if cleanup has been run
      if (!cleanup) {
        setState(true)
      }
    })
  }

  process()

  // set the flag
  return () => {
    cleanup = true
  }
}, [])

JakubKotrs said on my post. "StrictMode" has been designed to run effects twice. and when I removed "StrictMode" on my index.js. it runs only once.





相关问题
read a .sdf (SQL Server CE) in php

I have a file called PhotoGallery.sdf and was wondering how to connect to this db with php, or if it is even possible? Maybe point me to the right documentation. I found query strings for this, but ...

Compare two .sdf files in .Net

I am working on windows application from where user will be able to get the backup of .sdf file and later user will be able to restore the .sdf file. Before file restoring file from my .Net ...

Database file .sdf does not update after closing application

I am creating a Desktop application using Microsoft Visual Studio .NET 2008. I am using a .sdf file as my database. My problem is that when I am making changes to my records (add new, deleted, updated)...

SDF file creation for window mobile 6.5

I create a vs 2005 project and a sdf file using ms sql server express 2005. And I try to connect it in MC65. I got this error The database file has been created by an earlier version of SQL ...

Binding WPF ComboBox in XAML - Why is it Empty?

I am trying to learn how to bind my simple database (.sdf) to a combobox. I created a dataset with my tables in it. I then dragged a table from the DataSource onto my control. There are no build ...

热门标签