58
loading...
This website collects cookies to deliver better user experience
💡 We won’t be doing anything backend or API related. This is strictly converting a UI Kit to a production-ready mobile application with React Native.
💡 We can also use the default React Native styling to achieve the fancy look.
// Figure 1. Example of using styled-components
// Creating the Task component
import React from 'react'
import styled from 'styled-components/native';
interface TaskProps {
title: string;
}
const defaultProps: Partial<TaskProps> = {
title: 'Default task title',
};
const Task = ({ title }: TaskProps) => {
return <StyledTaskTitle>{title}</StyledTaskTitle>;
};
const StyledTaskTitle = styled.Text`
font-size: 16px;
color: black;
`;
Task.defaultProps = defaultProps;
export default Task;
// Using the Task component
import Task from '../components/Task';
...
<Task title={'Wireframing 😜'} />
💡 In Figure 1, we are using a self closing tag. We are not restricted to self closing tags alone, we can also use it as a non-self closing tag. We will see more examples of this in the coming chapters.
// Figure 2. Example of using styled system in our component
// Adding styled system to our Task component
import React from 'react'
import styled from 'styled-components/native';
import { color, ColorProps } from 'styled-system';
interface TaskProps {
title: string;
}
type Props = TaskProps &
ColorProps;
const defaultProps: Partial<TaskProps> = {
title: 'Default task title',
};
const Task = ({ title, ...restProps }: Props) => {
return <StyledTaskTitle {...restProps}>{title}</StyledTaskTitle>;
};
const StyledTaskTitle = styled.Text`
font-size: 16px;
${color};
`;
Task.defaultProps = defaultProps;
export default Task;
// Using the Task component with styled system props
import Task from '../components/Task';
...
<Task
bg={'#ffffff'}
color={'#000000'}
title={'Wireframing 😜'}
/>
➜ npm install —g expo-cli
➜ expo --version
4.13.0
response.➜ expo init TaskEz
✅ Your project is ready
To run your project, navigate to the directory and run one of the following yarn commands.
- cd TaskEz
- yarn start # you can open iOS, Android, or web from here, or run them directly with the commands below.
- yarn android
- yarn ios
- yarn web
yarn start
so run:➜ cd TaskEz
➜ TaskEz yarn start
yarn start
should fire up our browser and open up a new tab. The new tab that was automatically opened for us is one of the ways we can run TaskEz on our devices. Remember the Expo Go application we downloaded earlier? Now is the time we use it. Grab your devices and follow the steps below:💡 You need to have your mobile device and computer on the same network for the method below to work without any hiccups.
💡 By default, Expo uses yarn. If you want to force Expo to use NPM, you need to pass --npm while creating your Expo project, so you'd have expo init TaskEz --npm
.
› Metro waiting on exp://192.168.130.224:19000
› Scan the QR code above with Expo Go (Android) or the Camera app (iOS)
› Press a │ open Android
› Press i │ open iOS simulator
› Press w │ open web
› Press r │ reload app
› Press m │ toggle menu
› Press d │ show developer tools
› shift+d │ toggle auto opening developer tools on startup (enabled)
› Press ? │ show all commands
Logs for your project will appear below. Press Ctrl+C to exit.