Shopify / restyle

A type-enforced system for building UI components in React Native with TypeScript.

Home Page:https://shopify.github.io/restyle/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How would you approach animating with Restyle?

selbekk opened this issue Β· comments

I love Restyle, and we're basing our component library on it. However, how do you go about implementing animations? I couldn't find any resources on how to set up animations with it online, or in the docs.

Could somebody give me some pointers? πŸ™πŸ»

You can createAnimatedComponent and provide animated styles, for example

import { createBox, createText } from '@shopify/restyle';
import { Animated } from 'react-native';
import type { Theme } from './theme';

export const Box = createBox<Theme>();
export const Text = createText<Theme>();
export const AnimatedBox = Animated.createAnimatedComponent(Box);
export const AnimatedText = Animated.createAnimatedComponent(Text);

Oh okay, that makes sense I guess – but how can I then transition from one variant to the next, for instance?

I assume you would need to get the primitive value from the theme object.