当我的文本字段被填充时,我试图触发一个 onchange 函数,但我不明白为什么这个函数永远不会被触发,即使 Chrome 的 React devtool 插件实际上触发了更改,有什么建议吗?
import React, {Component} from 'react';
import {Tracker} from 'meteor/tracker';
import {Meteor} from 'meteor/meteor';
import {Links} from '../api/links';
import LinkListItem from './LinkListItem';
import {Session} from 'meteor/session';
import SearchLink from './SearchLink';
import Fuse from 'fuse.js';
export default class LinkList extends Component {
constructor(props) {
super(props);
this.state = {
links: [],
inputValue: ''
};
}
componentDidMount() {
this.linksTracker = Tracker.autorun(() => {
Meteor.subscribe('links');
const links = Links.find({visible:
Session.get('showVisible')}).fetch();
this.setState({links});
});
}
componentWillUnmount() {
this.linksTracker.stop();
} …Run Code Online (Sandbox Code Playgroud) 我试图测试我的组件,但每次我的测试失败时,我都无法找出问题所在。
登录.test.js:
import { Meteor } from 'meteor/meteor';
import React from 'react';
import expect from 'expect';
import { mount } from 'enzyme';
import { Login } from './Login';
if (Meteor.isClient) {
describe("Login", function() {
it("should show error messages", function() {
const error = "This is not working";
const wrapper = mount(<Login loginWithPassword={() => {}}/>);
wrapper.setState({ error: error });
expect(wrapper.find("p").text()).toBe(error);
wrapper.setState({ error: "" });
expect(wrapper.find("p").length).toBe(0);
});
it("should called loginWithPassword with the form data", function() {
const email = "test@test.com";
const password …Run Code Online (Sandbox Code Playgroud)