Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- export default class SvcList extends React.Component {
- constructor(props) {
- super(props)
- this.state = {
- servicesArr: []
- }
- }
- changeSelectionsArray = (id) => {
- this.state.servicesArr.push(id)
- // THIS IS THE FUNCTION SENDING THE ARRAY TO SECOND COMPONENT
- this.props.reviseServicesArray(this.state.servicesArr)
- }
- render() {
- return(
- <div><button id="something" onClick={() => this.changeSelectionsArray(id)}>Click Me</button></div>
- )
- }
- }
- ["5bd97355-50d8-4a06-aced-025c8cc587f3", "5bd97403-ae5b-4c90-92cb-130f86154e27"]
- export default class SvcDisplay extends React.Component {
- constructor(props) {
- super(props)
- }
- render() {
- const { servicesArr } = this.props;
- const serviceDisplay = servicesArr.map((item, i) => (
- <li key={i}>{item}</li>
- ));
- return(
- <div>
- <ul>{serviceDisplay}</ul>
- </div>
- )
- }
- }
- - 5bd97355-50d8-4a06-aced-025c8cc587f35bd97403-ae5b-4c90-92cb-130f86154e27
Add Comment
Please, Sign In to add comment