"The core premise for React is that UIs are simply a projection of data into a different form of data. The same input gives the same output. A simple pure function."
- React library README (https://github.com/reactjs/react-basic/blob/master/README.md).
- React library README (https://github.com/reactjs/react-basic/blob/master/README.md).
You will learn about pure functions later in this book. Check out the following example to understand the basics:
// Code example from React readme. Comments added for clarity.
// JavaScript pure function
// for a given input always returns the same output
function NameBox(name) {
return { fontWeight: 'bold', labelContent: name };
}
// Example with input
'Sebastian Markbåge' ->
{ fontWeight: 'bold', labelContent: 'Sebastian Markbåge' };
Going back to more practical examples, let's see how the preceding premise is implemented in React Native...