This document discusses developing client, server, and mobile applications with React. It introduces React Top-Level API vs JSX and how to create reusable Widget components in React that can render different content types specified by a string property. Widgets are demonstrated as cards with optional close and option buttons that can trigger callback handlers. The content is split across multiple nested components for reusability and extensibility. Similar capabilities in Angular are discussed using directives.
11. Javascript ES6 : La guida mancante in italiano
Corso completo di sviluppo web: crea da zero il tuo business
12. La Fabbrica di innovazione e sviluppo tecnologico
dei servizi core per le aziende.
INutile è anche il tuo successo professionale dei prossimi anni
www.inattivo.com
Progetto INutile
13. • Il marketplace che conne0e aziende e freelancer digitali
• Usa l’Ar:ficial Intelligence per la creazione di team di freelancer
• Un workspace Agile per la ges:one della collaborazione azienda - team
• Il primo marketplace collegato ad un ufficio 3D in Virtual Reality
• Iscrivi: alla newsle0er su h0ps://coderblock.com o sulla pagina facebook per
testare la pia0aforma in closed beta e ricevere i primi premi!
Il recruitment ai tempi del remote working.
17. JSX
• Many Angular / Javascript developers
think JSX is sh*t
• Why? Because of the HTML, CSS and JS “mix”
(in the same file)
18. JSX
In my opinion
JSX is one of the most interesting features in React
thanks to its flexibility
19. JSX
• JSX is a preprocessor step that adds XML syntax to JavaScript
• So, you can mix HTML, JS and CSS
• A simple way to update dynamically DOM
• You can definitely use React without JSX (thanks to React API)
(but JSX makes React a lot more elegant)
42. type AS CLASS NAME
<Widget title="Temperatures"
type={Chart}
config={temperatures} />
<Widget title=“User Profile"
type={Profile}
userID="123"/>
NOTE: each widget needs different properties to work
49. or by using .map()
COMPONENT:
props.widgets.map(item => (
<Widget
key={item.id}
{...item}
onClose={() => destroyWidget()}
onShowOptions={() => openOptions()}
/>
);
50. <widgetBody>: JSX version
COMPONENT:
const WidgetBody = props => {
switch(props.type) {
case 'Chart': return <Chart {...props} />;
case 'Profile': return <Profile {...props} />;
case 'Any': return <Any {...props} />;
default: return <h3>You forgot type</h3>;
}
};
51. <WidgetBody>: REACT API/eval version
COMPONENT:
const WidgetBody = props => {
const { type, ...others } = props;
return React.createElement( eval(type), {...others}, null )
}
If you run eval() someone could run malicious code on the user's machine