Week 9
This week consisted of finishing step 9 implementation, writing more of my Final Report, and working on Step 10.
Step 9 Continued
Fix:
- Updated
Buttonclass:class Button extends React.Component{ state = { hover: false } clickHandler(gridOutput){ changeGrid(gridOutput) } render(){ return( <View> <VrButton style = {this.state.hover ? styles.hover : styles.button} onEnter = {() => this.setState({hover: true})} onExit = {() => this.setState({hover: false})} onClick = {() => this.clickHandler(this.props.gridOutput)}> <Text style = {styles.code_display} > {this.props.code} </Text> </VrButton> </View> ); } }Step 10: Update memory panel to be in sync with snippets
How do I connect the buttons from
CodePanelto theGridPanel’s grid?
Attempts:
- Created a
changeGridfunction that would update the state of the codePanel and update the gridPanel accordingly by changing theoutputproperty. - Using the
connectfunction fromstore.js, I connected theCodePaneland theGridPanelso any update to theCodePanelwill change the state ofGridPanel. - Used the
connectfunction to connectGridArrayso thatgridOutputcould be accessed.
Error:
- Invariant Violation: Maximum update depth exceeded. This can happen when a component repeatedly calls setState inside componentWillUpdate or componentDidUpdate. React limits the number of nested updates to prevent infinite loops.
Fix:
setStatewas moved to onEnter/onExit- Fixed spelling typo in import changeGrid
Why are gridOutput and changeGrid undefined?
Error:
- TypeError: Cannot read property ‘0’ of undefined
- changeGrid is not defined
Fixes:
- gridOutput had to be included in the GridArray call: `<GridArray gridOutput = {this.props.gridOutput}/>
- Not really a fix because gridOutput is still undefined.
- Created a
const ConnectedGridArraywhich connectsGridArraytoGridPanelandCodePanel
Completed Tasks:
- Step 9
- Completed Week 8 & 9 Posts
- Read Research Papers
Unfinished Tasks:
- Continue Supplemental Courses
- Continue/ Edit Sections of Final Report
- Debug Magnifying Glass
- Steps 10 & 11
Written on July 27, 2020
