简体   繁体   English

react-addons-transition-group的componentWillLeave相当于React Native?

[英]react-addons-transition-group's `componentWillLeave` equivalent for React Native??

The componentWillLeave feature and the corresponding callback is a powerful feature I haven't seen in RN. componentWillLeave功能和相应的回调是RN中没有的强大功能。 Without it, you're always forced into producing very crappy code using additional states to make sure an element stays on the page/phone until its animation is complete, when ideally some boolean state from redux simply triggers the removal of the element while respecting its willleave animation. 没有它,您总是被迫使用其他状态来产生非常糟糕的代码,以确保元素停留在页面/电话上,直到其动画完成为止;理想情况下,redux中的某些布尔状态只是在尊重元素的情况下触发元素的移除willleave动画。

So does anyone have any ideas how to accomplish this consistently in RN without having to write custom code every time to make sure the element stays rendered until you animate it away?? 那么,有没有人有任何想法如何在RN中始终如一地做到这一点,而不必每次都编写自定义代码来确保元素保持渲染状态直到您将其动画化?

I know this is an old question, but I just landed here from a google search on the topic so I'll give my 2 cents on it. 我知道这是一个老问题,但是我只是通过Google搜索找到了该主题,因此我将为此付2美分。

This library should represent a 1:1 replacement for react-addons-transition-group for RN and comes with support for componentWillLeave method you can implement. 该库应该代表RN的react-addons-transition-group的1:1替代,并支持您可以实现的componentWillLeave方法。 It supports both componentWillEnter and componentWillLeave . 它支持componentWillEntercomponentWillLeave

Link to the library: react-native-transitiongroup 链接到库: react-native-transitiongroup

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM