Answer the question
In order to leave comments, you need to log in
Fake data in react state, props swiping?
Hello, I started creating components, threw an array of objects into the state, so that I can use it later.
It looks something like this:
type State = {|
open: boolean,
|};
class Navbar extends React.Component<Props, State> {
state = {
open: false,
trips: [
{
flights: [
[{ id: 753 }, { status: "closed" }, { created: 153131255800 }],
[{ id: 1232 }, { status: "opened" }, { created: 153131325800 }],
[{ id: 4532 }, { status: "opened" }, { created: 153231324800 }],
],
},
{
passengers: [
{ id: 115754321 },
{ category: "adult" },
{ firstname: "test" },
{ lastname: "test" },
],
},
],
};
handleToggle = () => {
this.setState(state => ({ open: !state.open }));
};
handleClose = () => {
this.setState({
open: false,
});
};
render() {
const { open, trips } = this.state;
return (
<div>
<button onClick={this.handleToggle}>Click</button>
{open && (
<ClickOutside onClickOutside={this.handleClose}>
<Menu trips={trips} />
</ClickOutside>
)}
</div>
);
}
}
export default Navigation;
Answer the question
In order to leave comments, you need to log in
what is array folding? if you don’t want to propdrill, then use redux and use your current state in it as initialState
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question