AnimatePresence and initial={false}
See original GitHub issueI have a issue with latest version 0.14.2
where initial now is supported https://github.com/nandorojo/moti/pull/102
If you are using react native tab navigation and open a tab where the elements should be hidden on mount. What happens is that it will run the animation going from “opacity .75” to “opacity 0” while the screen is mounted. The specific screen is mounted when visited. Expected behaviour is that it should not run the animation because of initial={false}
. I also tried adding animateInitialState={false}
to the Something element, but that did not change anything.
const editMode = false;
<AnimatePresence initial={false}>
{editMode && (
<Something
from={{ opacity: 0 }}
animate={{ opacity: 0.75 }}
exit={{ opacity: 0 }}
transition={{
type: 'timing',
duration: 250,
}}
/>
)}
</AnimatePresence>
Styles (style-components)
import styled from 'styled-components/native';
const Something = styled(MotiView)`
position: absolute;
background-color: #000000;
border-radius: 10px;
top: 0;
bottom: 0;
left: 0;
right: 0;
`;
The styles has nothing to do with it, i just pasted it anyway
Issue Analytics
- State:
- Created 2 years ago
- Comments:9 (5 by maintainers)
Top Results From Across the Web
[BUG] AnimatePresence initial={false} is applied to all ... - GitHub
<AnimatePresence initial={false}> suppresses initial state for all motion components below it in the render tree, not just descendants with ...
Read more >React - Framer motion: prevent initial prop from triggering
By setting initial={false} on AnimatePresence, components present when AnimatePresence first loads will start in their animate state.
Read more >Example Animations » 31. Animate Presence - The Framer book
That's easy: you just set the initial value of isVisible to false (by passing a false to the useState() .) const [isVisible, setVisible]...
Read more >Exit animation with `framer-motion` demystified
the exit one if false. This property will be injected to the AnimatedComponent by AnimatePresence thanks to the React.cloneElement API. So we ...
Read more >Animation with Framer-Motion - #6 AnimatePresence - YouTube
Get the starter project to follow along here: https://github.com/koss-lebedev/nordic-pixelsCheatsheet explaining the differences between ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thanks for the issue. I’m having a little trouble following. Can you make a snack (on iOS) reproducing, and explain what should have happened?
Can you also confirm the same happens with styled components?
Found the issue 🙄, it was error 40 🤣. My initial state was true, meaning that it was in first render
true
and then false just after since i got a useEffect that turned it into false.Thx for helping 👍