diff --git a/assets/templates/custom_fields/CommunityField.js b/assets/templates/custom_fields/CommunityField.js
index 2937da7..a622fd4 100644
--- a/assets/templates/custom_fields/CommunityField.js
+++ b/assets/templates/custom_fields/CommunityField.js
@@ -1,23 +1,22 @@
// field is only visible when record is submitted to a particular community
-import React, {useState, useEffect} from "react"
+import React, {Component} from "react"
import {TextField} from "react-invenio-forms"
-// I believe this needs to be a class component and then use something in the props
-// passed to the constructor to determine what community it's in.
+// ! Neither the values from useFormikContext nor the record from the props tell you what community the record is in.
+// ! We can only look for ?community=id in the URL which is only present when the record is submitted to a particular community.
export class CommunityField extends Component {
- constructor(props) {
- super(props)
- this.state = {
- community: this.props.community || this.props.record.community || "",
- }
- }
+ render() {
+ const {fieldPath} = this.props
+ const community = new URLSearchParams(window.location.search).get("community")
- render() {this.state.community == "community-id" &&
-
+ if (community === 'test') {
+ return
+ }
+ return null
}
}