Tag: reactjs

在create-react-app引导程序 – 在我的脚本之后反应加载,所以我的脚本具有低优先级

在create-react-app引导程序 – 在我的脚本之后反应加载,所以我的脚本具有低优先级。 我怎样才能改变它? 我不知道,因为无法更改react-create-app的webpackconfiguration。 在我的主要组件中,我补充道: import 'bootstrap/dist/css/bootstrap.css'; import 'bootstrap/dist/css/bootstrap-theme.css'; 然后在我的不同组件中添加这样的反应组件: import { Col, Navbar, Nav, NavItem } from 'react-bootstrap'

推()位置,更改地址栏中的URL,但它不呈现组件

我使用express作为nodeJs Web应用程序服务器,并使用react-redux-router push新位置push送到浏览器。 将地址栏中的地址从localhost:3000/admin更改为localhost:3000 ,它会保持在同一页面上。 我使用dispatch(push('/'))来执行作业。 logging器: [更新] 我使用这种解决scheme,但它并没有为我工作

在Node.js和React.js中确认密码

我正在学习如何在Node.js和React.js中进行注册/loginfunction。 我正在尝试执行一个确认密码function,用户在注册时需要第二次input密码。 我已经创build了一个字段来确认React.js中的密码。 当我试图执行并testing它时,即使我input了正确的密码,也得到了“密码不匹配”。 我不知道哪里出了问题。 以下是我正在使用密码确认function的代码: function validateSignupForm(payload) { const errors = {}; let isFormValid = true; let message = ''; if (!payload || typeof payload.email !== 'string' || !validator.isEmail(payload.email)) { isFormValid = false; errors.email = 'Please provide a correct email address.'; } if (!payload || typeof payload.password !== 'string' || payload.password.trim().length < 8) { […]

为什么浏览器返回意外的input结束时,我可以从浏览器获取API响应?

我有一个非常基本的反应前端和一个非常基本的nodejs服务器。 我试图validation服务器上的用户名和密码,当客户端点击提交,然后最终redirect到他们的仪表板。 现在我无法发送用户数据请求了。 这是我在服务器上非常基本的身份validationfunction,身份validation和searchusers等function不是asynchronous的。 // Authorization app.get('/auth/:userId/:hash', function(req, res){ var id = req.params.userId.toString(); var hash = req.params.hash.toString(); var error = { err: 'something went wrong!' } var user = dm.searchUser(id, users); if (!user){ res.json(error); } var isAuthenticated = dm.authenticate(user, hash); if (!isAuthenticated){ res.json(error); } if(isAuthenticated){ console.log('authed') res.json(user); } }); 这是处理表单提交行为的客户端反应组件方法。 submit(e){ e.preventDefault(); const BASE_URL = […]

在浏览器中使用Webpack和mocha-loader从React应用程序运行Mocha规范

我有一个应用程序,我想在浏览器中运行它的mocha规格(unit testing)。 我发现这个SOpost,并试图将相同的想法应用到我的项目。 我想出了下面的webpackconfiguration文件: webpack.config.test.js const nodeExternals = require('webpack-node-externals'); const path = require('path'); const host = 'localhost'; const port = '8084'; module.exports = { target: 'web', externals: [nodeExternals()], entry: './specs/index.js', output: { filename: 'debug.bundle.js', path: path.join(__dirname, 'tests'), publicPath: `http://${host}:${port}/tests`, }, devServer: { host, port, }, module: { rules: [ { test: /\.js$/, loaders: ['react-hot-loader', 'babel-loader'], […]

同构应用程序中的用户configuration文件

我目前正在使用React,Redux,Express和Node来添加login,以及一系列与login相关的高级function。 对于实际的login,我使用Passport,使用Facebook,Google和Twitter策略。 获取所需的令牌后,会将其发送到AWS Cognito联合身份标识以获取用户的同步数据。 来自网站的数据也会在需要时同步回Cognito。 在用户login后,我可以在Node服务器上构build一个完整的用户configuration文件,但是现在呢? // server.jsx // imports …………. // variables …………. var userProfile; // logging the user with Passport and adding it to the profile …………. app.use((req, res) => { // I can do whatever I want with the profile here …………. // handling the request and creating an initial state .. […]

JQuery插件给出错误$(…).ionRangeSlider不是一个函数

我正在尝试在我的反应中使用jquery插件。 每次我尝试使用一些jQuery的第三方插件,我得到一个错误说$(…)。somePlugin不是一个函数。 目前我正在尝试使用ionRangeSlider。 这是给我错误 Uncaught TypeError: (0 , _jquery2.default)(…).ionRangeSlider is not a function js文件 import $ from 'jquery' import 'bootstrap-tagsinput' class AddTagSection extends Component { componentDidMount=()=> { this.slider = $(this.inputSlider).ionRangeSlider(); } <div className="irs-wrapper"> <input type="text" ref={node=>this.inputSlider=node} className='input-slider' id="ionSlider-newTag" name="ionSlider"/> </div> 下面是在ionRangeSlider.js(插件)中调用的函数 $.fn.ionRangeSlider = function (options) { return this.each(function() { if (!$.data(this, "ionRangeSlider")) { $.data(this, "ionRangeSlider", […]

猫头鹰旋转木马2服务器端渲染Reactjs

我在猫头鹰旋转木马2上工作。我想在服务器端渲染中给予支持在使用纱线的Reactjs中可能吗? 请给我一个使用Reactjs for Owl Carousel 2的服务器端渲染的例子。

TypeError:无法读取未定义的属性'createTableIfNotExists'

我有一个knex的问题,并迁移我的表,所以我这样做 knex migrations:make users ,然后在我定义的迁移文件中: exports.up = function(knex, Promise) { return knex.shema.createTableIfNotExists('users', (table) => { table.increment(); table.string('username').unique().notNullable; table.string('password').notNullable(); table.boolean('admin').notNullable().defaultTo(false); table.timestamp('created_at').notNullable().defaultTo(knex.raw('now()')); }) }; exports.down = function(knex, Promise) { return knex.shema.dropTableIfExists('users'); }; 然后,我运行knex migrate:latest –env development ,我有这个错误: Using environment: development Knex:warning – migrations failed with error: Cannot read property 'createTableIfNotExists' of undefined TypeError: Cannot read property 'createTableIfNotExists' […]

如何使用摩卡在reactjs中testing这个asynchronous方法调用

// Balance.jsx … updateToken () { const parseResponse = (response) => { if (response.ok) { return response.json() } else { throw new Error('Could not retrieve access token.') } } const update = (data) => { if (data.token) { this.data.accessTokenData = data } else { throw new Error('Invalid response from token api') } } if (this.props.balanceEndpoint […]