Something went wrong. Try again.
[READ-ONLY] Mirror of https://github.com/DogPawHat/react-list-interview. Post-interview implementation of a list I was meant to do on a whit
Something went wrong. Try again.
1234567891011121314151617181920212223242526272829303132333435363738394041424344import * as React from 'react';import ListInput from './ListInput';import List from './List';import ListCounter from './ListCounter';
class App extends React.Component { state = { input: '', list: [] }
constructor(props) { super(props); } changeInput = (newInput) => { this.setState({input: newInput}) } addItem = (newItem) => { this.setState((prevState) => { const newItems = prevState.list.concat([prevState.input]); return {list: newItems}; }) } removeItem = (itemIndex) => { this.setState((prevState) => { const newItems = prevState.list.filter((v ,item) => { return (itemIndex != item) }); return {list: newItems}; }); } render() { return( <div> <ListInput input={this.state.input} changeInput={this.changeInput} addItem={this.addItem}/> <List list={this.state.list} removeItem={this.removeItem}/> <ListCounter count={this.state.list.length}/> </div> ) }}
export default App;