Skip to content

Instantly share code, notes, and snippets.

export type BrowsersListProps = {
loading: boolean
browsers: Browser[]
modalVisible: boolean
description: string
changeDescription: (description: string) => void
changeOpacity: () => void
}
import {useEffect, useState} from 'react'
import {BrowsersListProps} from '../components/BrowsersList'
export function useBrowsers(url: string): BrowsersListProps {
const [loading, setLoading] = useState(true)
// ...
// ...
export type Browser = {
fullname: string // we expect "fullname" Browser field to be a string
image: string
linkToBrowser: string
minMemory: string
currentVersion: string
minimumRAM: string
description: string
export type Browser = {
fullname: string // we expect "fullname" Browser field to be a string
image: string
linkToBrowser: string
minMemory: string
currentVersion: string
minimumRAM: string
description: string
windows: boolean
mac: boolean
// useBrowsers.js
...
return {
loading,
browsers,
modalVisible,
descripton,
changeDescription,
changeOpacity,
}
import React from 'react'
import {BrowsersList} from './components/BrowsersList'
import {useBrowsers} from './hooks/useBrowsers'
export function Browsers() {
return <BrowsersList {...useBrowsers('https://google.com/myData.json')} />
}
import React from 'react'
import {FlatList, StyleSheet, View} from 'react-native'
import AddModal from '../../../components/AddModal'
import LoadingIndicator from '../../../components/LoadingIndicator'
import BrowserItem from '../../../components/BrowserItem'
const styles = StyleSheet.create({
container: {
justifyContent: 'center',
alignItems: 'center',
import React, {useEffect, useState} from 'react'
import {FlatList, StyleSheet, View} from 'react-native'
import AddModal from '../components/AddModal'
import LoadingIndicator from '../components/LoadingIndicator'
import BrowserItem from '../components/BrowserItem'
const styles = StyleSheet.create({
container: {
justifyContent: 'center',
function Browsers({url = 'https://google.com/myData.json'}) {
const URL = url
...
import React, { useEffect, useState } from 'react';
import { FlatList, Text, View, StyleSheet, Modal, TouchableOpacity } from 'react-native';
import AddModal from '../components/AddModal';
import LoadingIndicator from '../components/LoadingIndicator'
import BrowserItem from '../components/BrowserItem'
import colors from '../config/colors';
function Browsers() {