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.
yarn add @kode-frontend/pathfinder-rnimport {
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>
);
}| 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 |
| onChangeEnvironment | (env: string) => void | Callback for change environment |
| renderContent | ({ close }) => ReactNode | Render prop for custom content |
open- <prefix>://pathfinder/openclose- <prefix>://pathfinder/close
release - create release tag and increase version