Listing 10-8: Importing Multiple Styles
Look Out!
import {warningStyle,infoStyle,successStyle} from './messageStyles';
function DisplayStatus(props){
let messageStyle;
switch(props.message.type){
case 'warning':
messageStyle = warningStyle;
break;
case 'info':
messageStyle = infoStyle;
break;
case 'success':
messageStyle = successStyle;
break;
default:
messageStyle = infoStyle;
break;
}
return (
<p style={messageStyle}>{props.message.text}</p>
);
}
export default DisplayStatus;
Download the examples, report issues, and ask/answer questions in the discussion area by visiting the book's github page. All of the code for the book is also available on codesandbox.io for you to play around with.
ReactJS Foundations is published by John Wiley and Sons, Inc and is available in paperback and eBook.