Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix deprecated lifecycle method usage in tests #318

Merged
merged 2 commits into from
Jan 4, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions __test_utils__/DynamicInputForm.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import * as React from 'react';
import Formsy from '../src';
import TestInput from './TestInput';

interface DynamicInputFormProps {
onSubmit: (model: any) => void;
inputName?: string;
}

class DynamicInputForm extends React.Component<DynamicInputFormProps> {
public state = {
input: null,
};

private addInput = () => {
const { inputName } = this.props;
this.setState({
input: <TestInput name={inputName} value="" />,
});
};

public render() {
return (
<>
<Formsy onSubmit={this.props.onSubmit}>
{this.state.input}
{this.props.children}
</Formsy>
<button type="button" onClick={this.addInput} />
</>
);
}
}

export default DynamicInputForm;
4 changes: 2 additions & 2 deletions __tests__/Element-spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@ describe('Element', () => {
it('should return true or false when calling isValid() depending on valid state', () => {
let isValid = null;
const Input = InputFactory({
componentWillReceiveProps: function(nextProps) {
isValid = nextProps.isValid;
componentDidUpdate: function() {
isValid = this.props.isValid;
},
});
const form = mount(
Expand Down
Loading