<commit_before>import React from 'react';
import { Link } from 'react-router';

export default class StaticInput extends React.Component {
	constructor(props) {
		super(props);
		this.state = {
			value: this.props.value
		};
	}
	setValue(props) {
		if (this.props.fieldType == 'Reference' && props.value) {
			feathers_app.service('attributes').get(props.value)
				.then(attribute => { this.setState({ value: attribute.value }); })
				.catch(console.error);
		}
		else {
			this.setState({ value: props.value });
		}
	}
	componentWillReceiveProps(nextProps) { this.setValue(nextProps); }
	componentDidMount() { this.setValue(this.props); }
	render() {
		return (
			<span>
				{this.props.fieldType == 'Reference' &&
					<Link style={{float:'right'}} to={'/workspace/'+this.props.workspace+'/collection/'+this.props.collection+'/reference/'+this.props.thing+'/'+this.props.field}>
						<i className="fa fa-edit" />
					</Link>
				}
				{this.state.value}
			</span>
		);
	}
}
<commit_msg>keep references up to date across collections<commit_after>import React from 'react';
import { Link } from 'react-router';

export default class StaticInput extends React.Component {
	constructor(props) {
		super(props);
		this.state = {
			value: this.props.value
		};
	}
	setValue(props) {
		if (this.props.fieldType == 'Reference' && props.value) {
			feathers_app.service('attributes').get(props.value)
				.then(attribute => { this.setState({ value: attribute.value }); })
				.catch(console.error);
		}
		else {
			this.setState({ value: props.value });
		}
	}
	handlePatchedAttribute(attribute) {
		if (this.props.value == attribute._id) {
			this.setValue(this.props);
		}
	}
	componentWillReceiveProps(nextProps) {
		this.setValue(nextProps);
	}
	componentDidMount() {
		this.setValue(this.props);
		if (this.props.fieldType == 'Reference') {
			this.attributePatchedListener = this.handlePatchedAttribute.bind(this);
			feathers_app.service('attributes').on('patched', this.attributePatchedListener);
		}
	}
	componentWillUnmount() {
		if (this.props.fieldType == 'Reference') {
			feathers_app.service('attributes').removeListener('patched', this.attributePatchedListener);
		}
	}
	render() {
		return (
			<span>
				{this.props.fieldType == 'Reference' &&
					<Link style={{float:'right'}} to={'/workspace/'+this.props.workspace+'/collection/'+this.props.collection+'/reference/'+this.props.thing+'/'+this.props.field}>
						<i className="fa fa-edit" />
					</Link>
				}
				{this.state.value}
			</span>
		);
	}
}

{'fraction_non_alphanumeric': 0.17372378314206569, 'fraction_numerical': 0.0, 'mean_word_length': 3.9861932938856017, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5923430', 'n_tokens_mistral': 940, 'n_tokens_neox': 842, 'n_words': 128}