Skip to content

appKODE/pathfinder-rn

Repository files navigation

🚧 🚧 🚧 THIS PROJECT HAS EXPERIMENTAL STATUS, DON'T USE IT 🚧 🚧 🚧

MIT license Current npm package version Downloads Total downloads

pathfinder-rn

This is a library for integrating a pathfinder into your application. The library is easy to integrate into an existing project and does not require any further development.

Installation

yarn add @kode-frontend/pathfinder-rn

Usage

import {
  createPathfinder,
  PathfinderConfiguration,
} from '@kode-frontend/pathfinder-rn';
import AsyncStorage from '@react-native-async-storage/async-storage';

import petstore from '../petstore.json';
import users from '../users.json';

const config = PathfinderConfiguration
  // create pathfinder configuration with default settings for mock server
  // default mock server settings are optional
  .create({
    domain: 'https://127.0.0.1:3100',
    headers: {
      Accept: 'application/json',
    },
    queryParams: {
      __dynamic: false,
    },
  })
  // add specification
  .addScheme({
    name: 'petstore',
    specification: petstore,
  })
  .addScheme({
    name: 'users',
    specification: users,
    // if needed set specific mock server settings for scheme
    // optional
    server: {
      domain: 'https://1.1.1.1/some/path',
      headers: {
        Accept: 'application/json',
      },
      queryParams: {
        __dynamic: false,
      },
    },
  });

// creating native pathfinder component
const Pathfinder = createPathfinder(config, AsyncStorage);

export default function App() {
  const [environment, setEnvironment] = React.useState('dev');
  return (
    <Pathfinder
      initialEnvironment={environment}
      environments={['dev', 'prod']}
      onChangeEnvironment={setEnvironment}
      devMode
      autostartForDev
    >
    	<YourApp />
    </Pathfinder>
  );
}

Props

prop name type description
initialEnvironment string Initial environments, should be static (required)
environments string[] List of environments (required)
devMode boolean Allows you to output information for developers to the console
autostartForDev boolean Launches the pathfinder when the application is launched in dev mode

Toggle devtools with Deep Links

  • open - <prefix>://pathfinder/open
  • close - <prefix>://pathfinder/close

Tags

release - create release tag and increase version