BlueBase
  • 💧Introduction
  • Tutorial
    • 1. Getting Started
      • 1.1 Setup
      • 1.2 Add Plugins
      • 1.3 Create Custom Plugin
    • 2. Backend API
      • 2.1 Create Backend API
      • 2.2 Setup Apollo Client
      • 2.3 Generate Typescript Interfaces
    • 3. Create Screens
      • 3.1 Pending Tasks Screen
      • 3.2 Edit Task Screen
      • 3.3 Task Create Screen
      • 3.4 Tab Navigation
    • 4. CRUD Operations
      • 4.1 Creating Tasks
      • 4.2 Reading Tasks
      • 4.3 Updating Tasks
      • 4.4 Deleting Tasks
    • 5. Enhancements
      • 5.1 Internationalisation
      • 5.2 Theming
      • 5.3 Dynamic Images
      • 5.4 Settings & Configurations
      • User Management
  • Key Concepts
    • 🎡Lifecycle Events
    • â›Šī¸Main App Layout
    • 🔌Plugins
      • Plugin API
      • Register a Plugin
      • Making a Plugin Configurable
      • Developing an Analytics Plugin
      • Developing a Logger Plugin
      • Developing a Theme Plugin
    • 🚇Filters
    • 🎁Components
      • Components API
      • Registering a Component
      • Accessing Components
      • Higher Order Components
    • 🎨Themes
      • Consuming Selected Theme
      • Customise Themes
      • Customise Components
      • Theme Configs
      • Theme Structure
    • đŸŽ›ī¸Configs
  • API
    • 📈Analytics
    • 📔Logger
    • đŸ“ĻBlueBase Modules
    • Registry
  • Guides
    • âœ‚ī¸Code Splitting
    • đŸ‘ŊMigrating to V8
  • Components
    • ActivityIndicator
    • BlueBase
      • BlueBaseApp 📌
      • BlueBaseConsumer 📌
      • BlueBaseFilter 📌
      • ThemeConsumer 📌
    • Button
    • ComponentState 📌
    • EmptyState 📌
    • ErrorState 📌
    • Icons
      • Icon
      • DynamicIcon 📌
      • PluginIcon 📌
    • JsonSchema 📌
    • LoadingState 📌
    • Noop 📌
    • Observers
      • DataObserver 📌
      • ErrorObserver 📌
      • HoverObserver 📌
      • WaitObserver 📌
    • StatefulComponent 📌
    • Typography
    • View
Powered by GitBook
On this page
  • Usage
  • Icon
  • Image
  • Component
  • Properties

Was this helpful?

Export as PDF
  1. Components
  2. Icons

DynamicIcon 📌

PreviousIconNextPluginIcon 📌

Last updated 6 years ago

Was this helpful?

An enhanced Icon that can render any of the following:

  • BB.Components.Icon

  • BB.Components.Image

  • A custom component

System Component 📌

This component is shipped with BlueBase Core.

Usage

Icon

The following example shows how to use component:

import { DynamicIcon } from '@bluebase/core';

// Then somewhere in your app:
<DynamicIcon
    type="icon"
    size={250}
    name="rocket"
/>

Image

The following example shows how to use an image as an icon:

<DynamicIcon
    type="image"
    size={250}
    source={{ uri: 'https://picsum.photos/200' }}
/>

Component

The following example shows how to use a custom component as an icon:

const CustomComponent = ({ size }: { size: number }) => (
	<View style={{ height: size, width: size, backgroundColor: 'red' }} />
);

// Then somewhere in your component:		
<DynamicIcon
    type="component"
    size={250}
    component={CustomComponent}
/>

It is also possible to use a component registered in the ComponentRegistry by using it's name:

<DynamicIcon
    type="component"
    size={250}
    component="CustomComponent" // equivalent to BB.Components.resolve('CustomComponent')
/>

Properties

prop

type

required

default

description

type

'component' | 'icon' | 'image'

yes

-

If value is:

  • component: Icon is a custom component, and looks for 'component' prop

  • icon: Icon is an instance of BB.Components.Icon and looks for 'icon' prop

  • image: Icon is an instance of BB.Components.Image and looks for 'source' prop

component

React Component | string

-

-

Used when type is 'component'. Either a component or a component name (string). In case of string, it will be fetched from Component Registry.

name

string

-

-

Used when type is 'icon'. This is the name prop of the BB.Components.Icon component

source

Image Source Prop Type

-

-

Used when type is 'image'. This is the Image source.

size

number

-

100

Icon size.

testID

string

no

-

Used to locate this view in end-to-end tests.

BlueBase Icon