1.3.11版本h5不能正常使用render开头的属性



  • cli版本: 1.3.11

    # MouseA.jsx
    import {View} from "@tarojs/components";
    import PropTypes from "prop-types";
    import {useState} from "@tarojs/taro";
    
    function MouseA({renderCat}) {
      const [pos] = useState({ x: 0, y: 0});
      return (
        <View>
          {renderCat(pos)}
        </View>
      )
    }
    
    MouseA.propTypes = {
      renderCat: PropTypes.func,
    };
    
    export default MouseA
    
    # Index.jsx
    import { View} from '@tarojs/components'
    import MouseA from  './MouseA'
    
    function IndexPage() {
      return (
        <View>
          <MouseA renderCat={mouse => (
            <View>MouseA 3</View>
          )}
          />
        </View>
      )
    }
    
    export default IndexPage
    

    运行错误提示

    TypeError: renderCat is not a function
        at MouseA.render (MouseA.js?946e:12)
        at eval (index.esm.js?eb37:1761)
        at errorCatcher (index.esm.js?eb37:1655)
        at renderComponent (index.esm.js?eb37:1760)
        at mountComponent (index.esm.js?eb37:1733)
        at ComponentWrapper.init (index.esm.js?eb37:2137)
        at createElement (index.esm.js?eb37:1398)
        at mountChild (index.esm.js?eb37:1463)
        at mountVNode$1 (index.esm.js?eb37:1453)
        at createElement (index.esm.js?eb37:1403)
    (anonymous) @ index.esm.js?eb04:2473
    Promise.catch (async)
    updateComponent @ index.esm.js?eb04:2472
    componentDidMount @ index.esm.js?eb04:2481
    (anonymous) @ index.esm.js?eb37:1779
    errorCatcher @ index.esm.js?eb37:1655
    (anonymous) @ index.esm.js?eb37:1778
    flushMount @ index.esm.js?eb37:1774
    updateComponent @ index.esm.js?eb37:1868
    rerender @ index.esm.js?eb37:1938
    Promise.then (async)
    nextTick @ index.esm.js?eb37:73
    enqueueRender @ index.esm.js?eb37:1926
    setState @ index.esm.js?eb37:1966
    push @ index.esm.js?eb04:2645
    componentDidMount @ index.esm.js?eb04:2719
    (anonymous) @ index.esm.js?eb37:1779
    errorCatcher @ index.esm.js?eb37:1655
    (anonymous) @ index.esm.js?eb37:1778
    flushMount @ index.esm.js?eb37:1774
    render @ index.esm.js?eb37:2057
    (anonymous) @ app.js?d0a8:74
    ./.temp/app.js @ app.js:915
    __webpack_require__ @ app.js:767
    fn @ app.js:130
    0 @ app.js:2166
    __webpack_require__ @ app.js:767
    (anonymous) @ app.js:902
    (anonymous) @ app.js:905
    


  • # package.json
    {
    	"name": "Taro-demo",
    	"version": "1.0.0",
    	"private": true,
    	"description": "",
    	"scripts": {
    		"build:weapp": "taro build --type weapp",
    		"build:swan": "taro build --type swan",
    		"build:alipay": "taro build --type alipay",
    		"build:tt": "taro build --type tt",
    		"build:h5": "taro build --type h5",
    		"build:rn": "taro build --type rn",
    		"dev:weapp": "npm run build:weapp -- --watch",
    		"dev:swan": "npm run build:swan -- --watch",
    		"dev:alipay": "npm run build:alipay -- --watch",
    		"dev:tt": "npm run build:tt -- --watch",
    		"dev:h5": "npm run build:h5 -- --watch",
    		"dev:rn": "npm run build:rn -- --watch"
    	},
    	"author": "",
    	"license": "MIT",
    	"dependencies": {
    		"@tarojs/components": "1.3.11",
    		"@tarojs/router": "1.3.11",
    		"@tarojs/taro": "1.3.11",
    		"@tarojs/taro-alipay": "1.3.11",
    		"@tarojs/taro-h5": "1.3.11",
    		"@tarojs/taro-swan": "1.3.11",
    		"@tarojs/taro-tt": "1.3.11",
    		"@tarojs/taro-weapp": "1.3.11",
    		"nerv-devtools": "^1.4.3",
    		"nervjs": "^1.4.3",
    		"react": "^16.8.6",
    		"taro-ui": "^1.5.4",
    		"prop-types": "latest"
    	},
    	"devDependencies": {
    		"@tarojs/plugin-babel": "1.3.11",
    		"@tarojs/plugin-csso": "1.3.11",
    		"@tarojs/plugin-sass": "1.3.11",
    		"@tarojs/plugin-uglifyjs": "1.3.11",
    		"@tarojs/webpack-runner": "1.3.11",
    		"@types/react": "^16.4.6",
    		"@types/webpack-env": "^1.13.6",
    		"babel-eslint": "^8.2.3",
    		"babel-plugin-transform-class-properties": "^6.24.1",
    		"babel-plugin-transform-decorators-legacy": "^1.3.4",
    		"babel-plugin-transform-jsx-stylesheet": "^0.6.5",
    		"babel-plugin-transform-object-rest-spread": "^6.26.0",
    		"babel-preset-env": "^1.6.1",
    		"eslint": "^4.19.1",
    		"eslint-config-taro": "1.3.11",
    		"eslint-plugin-import": "^2.12.0",
    		"eslint-plugin-react": "^7.8.2",
    		"eslint-plugin-taro": "1.3.11"
    	}
    }
    
    

登录后回复