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
| const getLogMetaData = () => ({ | |
| source: 'www' | |
| }); | |
| const withLogger = (ComposedComponent) => | |
| class extends React.Component { | |
| componentDidMount() { | |
| this.setState({ | |
| meta: getLogMetaData() | |
| }); |
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
| const getMessages = () => [ | |
| { id: 100, text: "Hey", author: "Ram" }, | |
| { id: 101, text: "Hello!", author: "Dennis" }, | |
| { id: 102, text: "How is it going?", author: "Ram" } | |
| ]; | |
| const MessagesPresenter = ({ messages }) => { | |
| return ( | |
| <ul> | |
| {messages.map(({ id, text, author }) => ( |
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, { useState, useEffect } from "react"; | |
| const getMessages = () => [ | |
| { id: 100, text: "Hey", author: "Ram" }, | |
| { id: 101, text: "Hello!", author: "Dennis" }, | |
| { id: 102, text: "How is it going?", author: "Ram" } | |
| ]; | |
| const useMessages = () => { | |
| const [messages, setMessages] = useState([]); |
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
| <Menu hideButtons> | |
| {(hideButtons) => ( | |
| <> | |
| <MenuButton display={!hideButtons} text="Exit" action={() => {...}} /> | |
| <MenuButton display={!hideButtons} text="Settings" action={() => {...}} /> | |
| <MenuItem text="News" /> | |
| <MenuItem text="Serials" /> | |
| <MenuItem text="Sports" /> | |
| </> | |
| )} |
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 Menu from "./Menu"; | |
| import MenuButton from "./MenuButton"; | |
| import MenuItem from "./MenuItem"; | |
| export default () => ( | |
| <Menu hideButtons> | |
| <MenuButton text="Exit" action={() => console.log("Exiting")} /> | |
| <MenuButton text="Settings" action={() => console.log("settings")} /> | |
| <MenuItem text="News" /> | |
| <MenuItem text="Serials" /> |
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
| const Button = ({ text, onClick, tabIndex, ariaDisabled }) => { | |
| return ( | |
| <button | |
| onClick={onClick} | |
| tabIndex={tabIndex} | |
| role="button" | |
| aria-disabled={ariaDisabled} | |
| > | |
| {text} | |
| </button> |
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
| const buttonAriaPropCollection = { | |
| tabIndex: 0, | |
| role: "button", | |
| "aria-disabled": false | |
| }; | |
| const Button = ({ text, onClick, tabIndex, role, 'aria-disabled': ariaDisabled }) => { | |
| return ( | |
| <button onClick={onClick} tabIndex={tabIndex} role={role} aria-disabled={ariaDisabled}> | |
| {text} |