无法读取未定义的属性'string'试图通过react-native-create-bridge理解React Native Native模块

时间:2018-09-19 06:29:12

标签: ios react-native react-native-native-module

我目前正在尝试制作this教程的Ios版本。
本教程简要介绍了通过react-native-create-bridge在react-native中使用本机模块

我应该在文本下方看到一个简单的蓝色框。但是,我收到未定义的错误“无法准备好属性”字符串。 enter image description here在检查了相关行并删除了.string部分之后。现在,该页面呈现,但是没有预期的蓝色框。

这是ThirdSquareNativeView.js的样子

 {foreach from=$histories key=year  item=i name=foo }
    {if $i.year >= date("Y")}
    {continue}
    {else}
   //how to initialise smarty variable here to 1;  
    {/if}
    <tr>
    <td><a href="{$urls.history_details|replace:'%s':$i.year}">{$smarty.foreach.foo.iteration}</a></td>
    <td><a href="{$urls.history_details|replace:'%s':$i.year}">{$i.year}</a></td>
    <td><a href="{$urls.history_details|replace:'%s':$i.year}">{$i.country}</a></td>
    <td><a href="{$urls.history_details|replace:'%s':$i.year}">{$i.location}    </a></td>

    </tr>

    {/foreach}

1 个答案:

答案 0 :(得分:1)

您需要安装和导入prop-types。它不再是React的一部分。

npm install prop-types --save

然后用作

import PropTypes from 'prop-types';

您的代码将类似于

ThirdSquareView.propTypes = {
  exampleProp: PropTypes.string
}