小编Nav*_*HKA的帖子

ReactJs CreateClass不是一个函数

var React = require('react');

module.exports=React.createClass({
   render:function(){
   return(
        <div>
           <h1> the list  </h1>
        </div>   
   )}
})
Run Code Online (Sandbox Code Playgroud)

当我运行上面的代码时,我收到以下错误:

app.js:4 Uncaught TypeError: React.createClass is not a function
Run Code Online (Sandbox Code Playgroud)

这是因为版本差异还是拼写错误?

package.json-I have included create-react-class as seen here but not in the bower.json file 


 {
    "dependencies": {
        "browser-sync": "^2.18.13",
        "browserify": "^14.4.0",
        "create-react-class": "^15.6.2",
        "ejs": "^2.5.7",
        "express": "^4.16.0",
        "gulp": "^3.9.1",
        "gulp-live-server": "0.0.31",
        "react": "^16.0.0",
        "reactify": "^1.1.1",
        "vinyl-source-stream": "^1.1.0"
      }
    }
Run Code Online (Sandbox Code Playgroud)

gulpfile.js -Am我在这个文件中遗漏了一些依赖项

var gulp= require('gulp');
var LiveServer= require('gulp-live-server');
var browserSync=require('browser-sync');
var browserify = require('browserify');
var reactify= require('reactify'); …
Run Code Online (Sandbox Code Playgroud)

reactjs

51
推荐指数
3
解决办法
7万
查看次数

在js中无法识别带有reg表达式的变量

我正在尝试使用slush生成模板,我的代码仓库在这里:https: //github.com/NaveenDK/slush-template-generator/blob/master/templates/react-native-app/MediaButtons.js

即使模板文件本身运行正常,当我尝试使用MediaButtons.js文件中的以下行使用slush生成时

 let match = /\.(\w+)$/.exec(filename);
    let type = match ? `image/${match[1]}` : `image`;
Run Code Online (Sandbox Code Playgroud)

我得到一个错误,说明'匹配'没有定义,当我用slush搭建它并且它在templates文件夹中时.我的猜测是reg表达式没有被正确解释

谢谢你的帮助!纳文

javascript regex variables undefined

9
推荐指数
1
解决办法
251
查看次数

无法解析模块“module://@babel/runtime/helpers/interopRequireDefault.js” - EXPO SNACK

当我尝试在 Expo Snack 中运行以下代码时,收到错误“无法解析模块 'module://@babel/runtime/helpers/interopRequireDefault.js '”

下面是我的 HomeScreen.js 代码

    import { StyleSheet, Text, View, FlatList } from "react-native";
    import axios from "axios";
    import { useState, useEffect } from "react";
    
    export default function HomeScreen() {
      const [cycles, setCycles] = useState([]);
    
      useEffect(() => {
        const fetchData = async () => {
          try {
            
    
            const { data: response } = await axios.get(
              "URL"
            );
    
            setCycles(response);
           
          } catch (error) {
            console.error(error.message);
          }
          
        };
    
        fetchData();
      }, []);
    
      return (
        <View style={styles.container}>
          {/* <Text> {JSON.stringify(cycles[0])} …
Run Code Online (Sandbox Code Playgroud)

npm babeljs react-native expo

6
推荐指数
1
解决办法
2062
查看次数

localhost的IP地址:8080-github + jenkins的webhooks

我正在尝试在github中配置webhooks以便每次我进行新推送时都会部署,我在github中添加了web钩子并给出了jenkins的地址http://localhost:8080/github-webhook/但是它没有用,我发现我们需要查找我们的IP地址和我添加如下:

http://'ipaddress'/github-webhook/
Run Code Online (Sandbox Code Playgroud)

但我仍然没有让詹金斯工作?谢谢

github ip-address webhooks jenkins

5
推荐指数
2
解决办法
4309
查看次数

Expo:React Native,“启动隧道时出错:错误:启动隧道超时”

我的设备和 PC 连接到同一网络,我们如何解决此错误,

重新启动后,它给出了相同的错误:

Switched to a LAN URL because the tunnel appears to be down. Only devices in the same network can access the app. You can restart the project to try reconnecting.
Run Code Online (Sandbox Code Playgroud)

在我的设备上它说

Tunnel packager ....exp.not found
Run Code Online (Sandbox Code Playgroud)

顺便说一句,我在 Windows 上运行;谢谢

reactjs react-native-ios expo

2
推荐指数
1
解决办法
9657
查看次数

React限制渲染次数以防止无限循环错误

下面是我的代码

function App() {
    const [isImportant, setIsImportant] = useState("Yes")
    
    
    function handleClick() {
        setIsImportant("No")
    }
    
    return (
        <div className="state">
            <h1 className="state--title">Is state important to know?</h1>
            <div className="state--value" onClick ={setIsImportant("No")} >
              {isImportant}
            </div>
        </div>
    )
}
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述

但是我收到错误消息“未捕获错误:重新渲染次数过多”。React 限制渲染数量以防止无限循环。”

如果有人能解释为什么会发生错误,将不胜感激!

javascript reactjs

2
推荐指数
1
解决办法
100
查看次数

每次点击都会增加JavaScript计数器?

我需要更正此代码,以便在每次单击时增加它.

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>Clicker</title>
    <meta name="description" content="">
    <style></style>
</head>
<body>
    <button>Click!</button>

<script>
    const counter = {
        cnt: 0,

        inc: function() {
            cnt++;
            console.log(cnt);
        }
    };

    const button = document.getElementsByTagName('button')[0];
    button.addEventListener('click', counter.inc, false);

</script>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)

我现在的解决方案工作正常,但不确定它背后的概念是什么,解决方案是:

inc: function() {
    counter.cnt++;
    console.log(counter.cnt);
}
Run Code Online (Sandbox Code Playgroud)

javascript const javascript-objects

0
推荐指数
1
解决办法
1141
查看次数