Skip to content

Animate an unknown component height #2918

Answered by MatiPl01
mydesweb asked this question in Q&A
Discussion options

You must be logged in to vote

You can achieve the same effect with layout animations by changing the height from 0 to auto and setting the layout property with e.g. LinearTransition on the animated component.

You have keep in mind that all other components, which layout will be affected by this layout animation, must also have the layout property specified. For example, in the code snipped below, I set the layout={LinearTransition} to the Animated.View, which height is modified, as well as to its sibling.

import React, { useState } from 'react';
import Animated, { LinearTransition } from 'react-native-reanimated';
import { Button, View } from 'react-native';

export default function EmptyExample() {
  const [show, set…

Replies: 2 comments 3 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
3 replies
@MatiPl01
Comment options

@neiker
Comment options

@MatiPl01
Comment options

Answer selected by MatiPl01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants