Skip to content

Conversation

@adam-ali
Copy link

Description

Fixes ()

Fixes tsc errors thrown in the migrating-to-v2 example in the README

Here's the example code from the README.

import {TouchableOpacity, View} from 'react-native';
import {
  useRestyle,
  spacing,
  border,
  backgroundColor,
  SpacingProps,
  BorderProps,
  BackgroundColorProps,
  composeRestyleFunctions,
} from '@shopify/restyle';

import Text from './Text';
import {Theme} from './theme';

const restyleFunctions = composeRestyleFunctions([
  spacing,
  border,
  backgroundColor,
]);
type Props = SpacingProps<Theme> &
  BorderProps<Theme> &
  BackgroundColorProps<Theme> & {
    onPress: () => void;
  };

const Button = ({onPress, label, ...rest}: Props) => {
  const props = useRestyle(restyleFunctions, rest);

  return (
    <TouchableOpacity onPress={onPress}>
      <View {...props}>
        <Text variant="buttonLabel">{label}</Text>
      </View>
    </TouchableOpacity>
  );
};

This is the error shown in the restyleFunctions being passed to the useRestyle hook.

Argument of type '{ buildStyle: (props: { [key: string]: any; }, { theme, dimensions, }: { theme: BaseTheme; dimensions: Dimensions | null; }) => RNStyle; properties: (string | number)[]; propertiesMap: { ...; }; }' is not assignable to parameter of type '{ buildStyle: <TInputProps extends { margin?: ResponsiveValue<"m" | "s" | "l" | "xl", {}> | undefined; marginTop?: ResponsiveValue<"m" | "s" | "l" | "xl", {}> | undefined; ... 43 more ...; backgroundColor?: ResponsiveValue<...> | undefined; }>(props: TInputProps, { theme, dimensions, }: { ...; }) => RNStyle; propert...'.

Screenshots or videos (if needed)

Screenshot 2024-09-15 174540

@adam-ali
Copy link
Author

I've signed the CLA!

@gvarandas gvarandas force-pushed the master branch 9 times, most recently from 334b3da to f86990a Compare March 19, 2025 21:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants