Created
November 19, 2021 04:02
-
-
Save natafaye/b32dc3b04824d11eed9f5e0791aa6be4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function App() { | |
const [channels, setchannels] = useState(INITIAL_CHANNELS) | |
const handleUpdateChannel = (updatedChannelData) => { | |
// set the state to the new updated data | |
} | |
return ( | |
<div> | |
<Sidebar channelList={ channels }/> | |
<Channel channel={ channels[0] } onUpdateChannel={ handleUpdateChannel } /> | |
</div> | |
); | |
} | |
export default App; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react' | |
export default function Channel(props) { | |
const onEditButtonClicked = () => { | |
props.onUpdateChannel | |
} | |
return ( | |
<div> | |
<h4>{ props.channel.name }</h4> | |
<MessageList messageList={ props.channel.messages } /> | |
<NewMessageForm /> | |
</div> | |
) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// example channels array | |
const INITIAL_CHANNELS = [ | |
{ | |
name: "onfdsfds-2021-07-14", | |
messages: [ | |
{ | |
author: "Natalie Childs", | |
text: "Welcome week 3", | |
unread: false | |
}, | |
{ | |
author: "fdsfdsfsd", | |
text: "I need help on something" | |
} | |
] | |
}, | |
{ | |
name: "onfdsfds-2021-19-14", | |
messages: [ | |
{ | |
author: "Natalie Childs", | |
text: "I need help on something" | |
}, | |
{ | |
author: "fdsfdsfsd", | |
text: "I need help on something" | |
} | |
] | |
} | |
] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react' | |
export default function MessageList(props) { | |
return ( | |
<div> | |
{ props.messageList.map(message => <Message message={message} /> )} | |
</div> | |
) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment