I'm extremely new to react and javascript so I'm sorry if I'm asking this wrong. This is for a group project which means I most likely don't understand the project 100%
- The older sibling has this nice prop that I want to use:
```
export default class OlderSibling extends Component {
state = {
currentCity: city //(that was gathered from a bunch of other steps)
};
render() {
return(
)
}
}
```
- The parent file doesn't have this prop, but it does have its own stuff. I do not care for these other props though.
```
class Parent extends Component {
constructor(props) {
super(props)
this.state = {
flower: 'red'
}
}
render() {
return (
<OlderSibling/>
<YoungerSibling/>
)
}
}
```
- The younger sibling (the one that wants current city) has a bunch of this.state properties that I do not want to share with others but just want the older sibling's stuff (I guess like what younger siblings normally do).
```
export class YoungerSibling extends Component {
constructor(props) {
super(props);
this.state = {
title: '',
description: []
}
}
render() {
return(
)
}
}
```
Just in case I wasn't clear, younger sibling just wants older sibling's this.state: currentCity that older Sibling worked so hard to gather.
I know I didn't put the code completely, but if you want to critique it anyway, please do! I am still learning and I welcome every bit of feedback!
I looked up ways to do this, but they're all about transferring parent to child which is not what I want. I also read that there was Redux that could handle this?? I don't know if my fellow groupmates are interested in that just yet.
Thank you for your time in reading this!
EDIT:
[ SOLVED ]
I just want to edit and say thank you to @soupette, @Liam, @[Denys Kotsur], and @Tomasz for helping me to understand react a bit more. I realize that this post was very much a spoon feeding request and you all helped away. Thank you!
Also, just in case anybody else ran into this issue, don't forget to call it on Younger Sibling as this.props.currentCity
.