Skip to content

Instantly share code, notes, and snippets.

@natafaye
Created November 19, 2021 04:02
Show Gist options
  • Save natafaye/b32dc3b04824d11eed9f5e0791aa6be4 to your computer and use it in GitHub Desktop.
Save natafaye/b32dc3b04824d11eed9f5e0791aa6be4 to your computer and use it in GitHub Desktop.
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;
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>
)
}
// 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"
}
]
}
]
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