Cannot make custom component

未关闭
#300 2 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
3/5
预计耗时
1-2 天
新手友好度
35/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
停滞
技术栈
react-native, typescript
领域
frontend

调研方向

Start by tracing the custom component example in the issue through Restyle's createRestyleComponent and createVariant implementation, then run the relevant tests or reproduce it in the fixture app. The report gives no test or file path; done means the documented custom-component use case works without the funcsMap error.

由索引模型根据 Issue 内容生成。

描述

bug

Current behavior

Getting an error with custom component (heads up- NOT typescript due to company regs)

Uncaught Error
funcsMap[key] is not a function
Source
 
 38 |
    
var
 mappedProps 
=
 funcsMap[key](props
,
 options)
;
 
 39 |
    
// eslint-disable-next-line guard-for-in
>
 40 |
    
for
 (
var
 mappedKey 
in
 mappedProps) {
 
    |
                          
^
 
 41 |
        styles[mappedKey] 
=
 mappedProps[mappedKey]
;
 
 42 |
    }
 
 43 |
}

This is the component (a basic page header)

import {Platform, StyleSheet, View, Text} from "react-native";
import {createRestyleComponent, createVariant} from "@shopify/restyle";
import {BoxRestyle} from "./theme";

const WebHeaderContainer = createRestyleComponent(
  [
    createVariant({
      themeKey: 'pageHeadVariants',
      defaults: {
      },
    }),
  ],
    BoxRestyle,
);

export default function WebHeader() {
    if (Platform.OS !== 'web') return null;
    return <WebHeaderContainer id='web-header'>
        <Text>Restyle Web Header</Text>
    </WebHeaderContainer>
}

// ----- theme

import {createTheme} from '@shopify/restyle';

const palette = {
  sacramentoGreen: '#083D33',
  bangladeshGreen: '#15664F',
  persianGreen: '#01B694',
  grannySmithYellow: '#01B694',
  perlAqua: '#85CFC4',

  black: '#000000',
  white: '#FFFFFF',
  gray_xxxl: 'rgba(0,0,0,0.95)',
  gray_xxl: 'rgba(0,0,0,0.85)',
  gray_xl: 'rgba(0,0,0,0.75)',
  gray_l: 'rgba(0,0,0,0.66)',
  gray_m: 'rgba(0,0,0,0.5)',
  gray_s: 'rgba(0,0,0,0.33)',
  gray_xs: 'rgba(0,0,0,0.25)',
  gray_xxs: 'rgba(0,0,0,0.25)',
  gray_xxxs: 'rgba(0,0,0,0.05)',
};

const theme = createTheme({
  colors: {
    mainBackground: palette.white,
    cardPrimaryBackground: palette.bangladeshGreen,
    pageHeaderBackgroundColor: palette.gray_xxxs,
    pageHeaderTintColor: palette.black,
    ...palette
  },
  spacing: {
    xs: 4,
    s: 8,
    m: 16,
    l: 24,
    xl: 32,
    xxl: 48
  },
  pageHeadVariants: {
    defaults: {
      width: '100%',
      height: '90px',
     display: 'flex',
      justifyContent: 'center',
      alignItems: 'center',
      flexDirection: 'column',
      backgroundColor: 'pageHeaderBackgroundColor',
    },
  },
  textVariants: {
    header: {
      fontFamily: 'PoppinsExtraBold',
      fontWeight: '800',
      fontSize: 34,
    },
    body: {
      fontFamily: 'Roboto',
      fontWeight: '400',
      fontSize: 16,
      lineHeight: 24,
    },
    defaults: {
      // We can define a default text variant here.
    },
  },
});

export default theme;

Expected behavior

the component works as documented in site...

To Reproduce

Platform:

Web / Expo

  • iOS
  • Android

Environment

"@shopify/restyle": "^2.4.4",
主要语言
TypeScript
星标
3.4k
派生
154
PR 合并指标
30 天内没有已合并 PR

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

Shopify/restyle 的其他 Issue

查看 Shopify/restyle 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。