Skip to content

TypeError: funcsMap[propKey] is not a function when using createText() #169

@davidbarker

Description

@davidbarker

The code below works as expected with v2.0.0 of Restyle, but when I upgrade to v2.1.0 I get the following error.

TypeError: funcsMap[propKey] is not a function. (In 'funcsMap[propKey](props, {
  theme: theme,
  dimensions: dimensions
})', 'funcsMap[propKey]' is undefined)

After some digging through my code, it appears that if I remove my <Title> component, this error goes away. So there's some issue with createText() perhaps?

I looked through the changelog for 2.0.0 → 2.1.0 but don't see anything obvious? If I replace my <Title> component with a plain <Text> component, it also works (but of course I lose the Restyle features).

import { createBox, createText } from '@shopify/restyle';
import React, {
  forwardRef,
  useImperativeHandle,
  useRef,
  useState,
} from 'react';
import { TouchableWithoutFeedback } from 'react-native';

import { Theme } from '~/theme/index';

import TextInput from './TextInput';

const InputWrapper = createBox<Theme>();
const OuterWrapper = createBox<Theme>();
const OutlineView = createBox<Theme>();
const Wrapper = createBox<Theme>();
const Title = createText<Theme>();

const SignInTextInput = (
  {
    title,
    ...rest
  }: {
    onChangeText: () => void;
    title: string;
    value: string;
  },
  ref: React.Ref<any>,
) => {
  const [isFocused, setIsFocused] = useState(false);
  const inputRef = useRef<any>();

  const focusInput = () => {
    inputRef.current?.focus();
  };

  useImperativeHandle(ref, () => ({
    focus: () => {
      focusInput();
    },
  }));

  return (
    <TouchableWithoutFeedback onPress={focusInput}>
      <OuterWrapper>
        <OutlineView
          backgroundColor={
            isFocused ? 'cardPrimaryBackground' : 'mainBackground'
          }
          bottom={-2}
          left={-2}
          position="absolute"
          right={-2}
          style={{
            borderRadius: 10,
          }}
          top={-2}
        />
        <Wrapper
          backgroundColor="mainBackground"
          borderColor="cardPrimaryBackground"
          borderWidth={1}
          padding="s"
          style={{
            borderRadius: 7.5,
          }}
        >
          <Title color="cardPrimaryBackground" fontSize={12}>
            {title}
          </Title>
          <InputWrapper flexDirection="row">
            <TextInput
              {...rest}
              onBlur={() => setIsFocused(false)}
              onFocus={() => setIsFocused(true)}
              ref={inputRef}
            />
          </InputWrapper>
        </Wrapper>
      </OuterWrapper>
    </TouchableWithoutFeedback>
  );
};

export default forwardRef(SignInTextInput);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions