Почему я получаю «Попытка удалить ребенка, которого не существует»? React Native - PullRequest
0 голосов
/ 14 апреля 2020

В настоящее время я работаю над заголовком, который получает информацию, и я хочу сделать некоторые анимации перехода между различными состояниями. Мой подход состоял в том, чтобы сделать анимацию с использованием ссылки и установить хук useState внутри обратного вызова завершения самой анимации. Но всякий раз, когда я делаю это, я получаю Пытаться удалить ребенка, которого не существует

const Home = () =>{
       const headerRef = useRef();
       ...
       return(<> ...
        <Header ... ref ={headerRef}/></>
       );
 }

const Header = forwardRef((props,ref)=>{ //called by Home component
     const [selected,setSelected] = useState(0)
     .
     .
     .
     useImperativeHandle(ref, () =>{
         onSelectedChange(id){
            if(id!=0){
            hideLogo(()=>{setSelected(id);});
            } 
        }
     }

}

, и появляется следующее предупреждение

Trying to remove a child that doesn't exist
 - node_modules\react-native\Libraries\YellowBox\YellowBox.js:71:8 in console.warn
 - node_modules\expo\build\environment\muteWarnings.fx.js:18:23 in warn- node_modules\react-native-reanimated\src\core\AnimatedNode.js:162:19 in __removeChild
 * http://192.168.0.36:19001/node_modules/expo/AppEntry.bundle?platform=ios&dev=true&minify=false&hot=false:168574:33 in __detach
 - node_modules\react-native-reanimated\src\core\InternalAnimatedValue.js:56:20 in __detachAnimation
 * http://192.168.0.36:19001/node_modules/expo/AppEntry.bundle?platform=ios&dev=true&minify=false&hot=false:168554:36 in <unknown>
 - node_modules\react-native-reanimated\src\core\AnimatedCall.js:8:27 in listener
 - node_modules\react-native\Libraries\vendor\emitter\EventEmitter.js:190:12 in emit
 - node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:436:47 in __callFunction
 - node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:111:26 in __guard$argument_0
 - node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:384:10 in __guard
 - node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:110:17 in __guard$argument_0
 * [native code]:null in callFunctionReturnFlushedQueueTrying to remove a child that doesn't exist
 - node_modules\react-native\Libraries\YellowBox\YellowBox.js:71:8 in console.warn
 - node_modules\expo\build\environment\muteWarnings.fx.js:18:23 in warn- node_modules\react-native-reanimated\src\core\AnimatedNode.js:162:19 in __removeChild
 * http://192.168.0.36:19001/node_modules/expo/AppEntry.bundle?platform=ios&dev=true&minify=false&hot=false:168574:33 in __detach
 - node_modules\react-native-reanimated\src\core\InternalAnimatedValue.js:56:20 in __detachAnimation
 * http://192.168.0.36:19001/node_modules/expo/AppEntry.bundle?platform=ios&dev=true&minify=false&hot=false:168554:36 in <unknown>
 - node_modules\react-native-reanimated\src\core\AnimatedCall.js:8:27 in listener
 - node_modules\react-native\Libraries\vendor\emitter\EventEmitter.js:190:12 in emit
 - node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:436:47 in __callFunction
 - node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:111:26 in __guard$argument_0
 - node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:384:10 in __guard
 - node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:110:17 in __guard$argument_0
* [native code]:null in callFunctionReturnFlushedQueue

Что я Со всем этим я узнал, что

  • Я почти уверен, что это не имеет ничего общего с ссылкой, я сделал то же самое в том же компоненте, и предупреждение все еще появляется.
  • приложение работает нормально, но при каждом переходе по этим компонентам появляется предупреждение.
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...