{"id":16795127,"url":"https://github.com/mehcode/rn-razor","last_synced_at":"2025-04-11T00:02:47.316Z","repository":{"id":143906710,"uuid":"62441571","full_name":"mehcode/rn-razor","owner":"mehcode","description":"Router for React Native with declarative configuration similar to React Router.","archived":false,"fork":false,"pushed_at":"2016-09-16T06:36:35.000Z","size":20,"stargazers_count":12,"open_issues_count":3,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-11T00:02:43.239Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mehcode.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-07-02T08:26:05.000Z","updated_at":"2017-03-22T06:09:29.000Z","dependencies_parsed_at":null,"dependency_job_id":"4811052c-b6d1-45cc-9dab-2d5fa47e9b1c","html_url":"https://github.com/mehcode/rn-razor","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mehcode%2Frn-razor","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mehcode%2Frn-razor/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mehcode%2Frn-razor/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mehcode%2Frn-razor/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mehcode","download_url":"https://codeload.github.com/mehcode/rn-razor/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248317701,"owners_count":21083528,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-13T09:15:29.884Z","updated_at":"2025-04-11T00:02:47.299Z","avatar_url":"https://github.com/mehcode.png","language":"JavaScript","readme":"# (React Native) Razor\n\u003e Router for React Native with declarative configuration similar to React Router.\n\n - Declarative configuration (using `\u003cRoute\u003e` similar to react-router)\n - Idiomatic React; no imperative API or self-contained state (unlike react-router)\n - Uses `NavigatorExperimental` (soon to replace `Navigator` and `NavigatorIOS` in core React Native)\n\n## Install\n\n```\nnpm install rn-razor --save\n```\n\n## Usage\n\n##### Configuration\n\n```javascript\nimport {Router, Route, StateUtils} from \"rn-razor\";\n\nclass Application extends React.Component {\n  state = {\n    routerState: StateUtils.create({initialRoute: \"index\"}),\n  };\n\n  render() {\n    \u003cRouter routerState={this.state.routerState}\u003e\n      \u003cRoute name=\"index\" component={Index} /\u003e\n      \u003cRoute name=\"profile\" component={Profile} /\u003e\n      \u003cRoute name=\"contacts\" component={ContactList} /\u003e\n      \u003cRoute name=\"contact\" component={ContactDetail} /\u003e\n    \u003c/Router\u003e\n  }\n}\n```\n\n##### Navigation\n\n```javascript\nimport {StateUtils} from \"rn-razor\";\n\nrouterState = StateUtils.push(routerState, \"profile\");\nrouterState = StateUtils.pop(routerState);\nrouterState = StateUtils.jumpTo(routerState, \"contact\", {id: 10});\nrouterState = StateUtils.resetTo(routerState, \"contact\", {id: 10});\n```\n\n## Reference\n\n### `\u003cRouter\u003e`\n\n##### `routerState`\n\nThe current state of navigation.\n\nCan be initialized to an initial route with `StateUtils.create({initialRoute: \"...\"})`.\n\n###### Example\n\n```\n{\n  index: 1,\n  routes: [\n    { name: \"index\" },\n    { name: \"contact-detail\", params: { id: 3 } },    \n  ]\n}\n```\n\n##### `children`\n\nA collection of `\u003cRoute\u003e` components providing the declarative configuration.\n\n##### `onWillFocus`\n\nCalled when a route is about to be rendered or \"focused\" (name comes from react-native). This is called after the route's `onEnter` (if present).\n\n##### `onDidFocus`\n\nCalled when a route has been rendered or \"focused\". This is called after the route component's `componentDidMount` (tip: good place to hide a splash screen from [rn-splash-screen](https://github.com/mehcode/rn-splash-screen)).\n\n##### `createElement`\n\nWhen the router is ready to render a specific scene, it will use this function to create the elements.\n\n###### Default\n\n```js\nfunction createElement(Component, props) {\n  return \u003cComponent {...props} /\u003e\n}\n```\n\n##### `render`\n\nWhen the router is ready to render the scene stack, it will use this function.\n\nUse this callback to add persistent views around the scene stack. Perhaps a navigation drawer or wrap `scenes` in `KeyboardAvoidingView` from react-native.\n\n###### Default\n\n```js\nfunction render(scenes) {\n  return scenes;\n}\n```\n\n### `\u003cRoute\u003e`\n\n##### `name`\n\nThe route key to use as a unique index during navigation.\n\n##### `component`\n\nThe component to be rendered for the route.\n\n##### `onEnter`\n\nCalled when a route is about to be entered.\n\n##### `onLeave`\n\nCalled when a route is about to be exited. Called before the next route's `onEnter`.\n\n##### `children`\n\nA collection of `\u003cRoute\u003e` components that are treated as a group, invoking their parent's `onEnter` and `onLeave` as a group. \n\nFor instance, a group of routes can be given a single `onLeave` or `onEnter` that is called when the router is no longer in the group or when entering the group for the first time.\n\nNote that a `\u003cRoute\u003e` cannot have both a `component` and `children` as component nesting is not currently supported.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmehcode%2Frn-razor","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmehcode%2Frn-razor","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmehcode%2Frn-razor/lists"}