diff --git a/src/components/MainDisplay.jsx b/src/components/MainDisplay.jsx index 6534e79..18cf864 100644 --- a/src/components/MainDisplay.jsx +++ b/src/components/MainDisplay.jsx @@ -7,7 +7,7 @@ import {WordForm} from './management/WordForm'; import {DictionaryDetails} from './display/DictionaryDetails'; import {WordsList} from './display/WordsList'; -export const MainDisplay = ({dictionaryInfo, wordsToDisplayPromise}) => { +export const MainDisplay = ({dictionaryInfo, wordsToDisplay, updateDisplay, lastRender}) => { return (
@@ -15,6 +15,7 @@ export const MainDisplay = ({dictionaryInfo, wordsToDisplayPromise}) => { updateDisplay()} partsOfSpeech={dictionaryInfo.partsOfSpeech} /> @@ -34,7 +35,8 @@ export const MainDisplay = ({dictionaryInfo, wordsToDisplayPromise}) => { /> + lastRender={lastRender} + words={wordsToDisplay} />
diff --git a/src/components/display/WordsList.jsx b/src/components/display/WordsList.jsx index 7392d80..9c77f36 100644 --- a/src/components/display/WordsList.jsx +++ b/src/components/display/WordsList.jsx @@ -15,15 +15,14 @@ export class WordsList extends Component { return (
- {this.props.wordsPromise - && this.props.wordsPromise.then(words => { - words.map(word => { + {this.props.words + && this.props.words.map(word => { return ( ); }) - })} + }
); diff --git a/src/components/management/WordForm.jsx b/src/components/management/WordForm.jsx index 96960e8..43e8bd6 100644 --- a/src/components/management/WordForm.jsx +++ b/src/components/management/WordForm.jsx @@ -72,6 +72,7 @@ export class WordForm extends Component { word.create() .then(() => { this.clearForm(); + this.props.updateDisplay(); }); } } diff --git a/src/index.jsx b/src/index.jsx index cca5360..4a3583a 100644 --- a/src/index.jsx +++ b/src/index.jsx @@ -23,6 +23,7 @@ class App extends Component { , specification: dictionary.specification , description: dictionary.description , partsOfSpeech: dictionary.partsOfSpeech + , displayedWords: [] , searchConfig: null } } @@ -39,11 +40,15 @@ class App extends Component { return info; } - get wordsToDisplayPromise () { + updateDisplayedWords () { // const {searchIn, searchTerm, filteredPartsOfSpeech} = this.state.searchConfig; // TODO: Sort out searching to remove this temporary solution. - return dictionary.wordsPromise; + dictionary.wordsPromise.then(words => { + this.setState({ + displayedWords: words + }) + }); } search (searchConfig) { @@ -60,7 +65,8 @@ class App extends Component { + wordsToDisplay={this.state.displayedWords} + updateDisplay={() => this.updateDisplayedWords()} />