diff --git a/src/components/Features.js b/src/components/Features.js
index 048d3d2..b93de9b 100644
--- a/src/components/Features.js
+++ b/src/components/Features.js
@@ -12,24 +12,27 @@ const parseFeaturesFromPhonemeObject = phonemeObject => {
return Object.keys(featureMap).map(feature =>
{`[+ ${feature}] = `}{featureMap[feature].join('|')});
}
+const getPhonemesFromFeatureSubmission = (props, newPhonemes, feature) => {
+ let newPhonemeObject = newPhonemes.split('/').reduce((phonemeObject, newPhoneme) => {
+ newPhoneme = newPhoneme.trim();
+ phonemeObject = phonemeObject[newPhoneme]
+ ? {...phonemeObject, [newPhoneme]: [...phonemeObject[newPhoneme], feature]}
+ : {...phonemeObject, [newPhoneme]: [feature]}
+ return phonemeObject;
+ }, {...props.phonemes})
+ return newPhonemeObject;
+}
+
const Features = (props) => {
const [feature, setFeature] = useState('nasal')
const [newPhonemes, setNewPhonemes] = useState('n / m / ŋ')
-
+
const newFeaturesSubmit = e => {
e.preventDefault();
- let newPhonemeObject = newPhonemes.split('/').reduce((phonemeObject, newPhoneme) => {
- // console.log([...phonemeObject[newPhoneme], feature])
- newPhoneme = newPhoneme.trim();
- phonemeObject = phonemeObject[newPhoneme]
- ? {...phonemeObject, [newPhoneme]: [...phonemeObject[newPhoneme], feature]}
- : {...phonemeObject, [newPhoneme]: [feature]}
- return phonemeObject;
- }, {...props.phonemes})
-
+ let newPhonemeObject = getPhonemesFromFeatureSubmission(props, newPhonemes, feature);
props.setPhonemes(newPhonemeObject);
-
+
setFeature('');
setNewPhonemes('');
}