{"id":18552442,"url":"https://github.com/andrejewski/raj-react","last_synced_at":"2025-04-09T22:31:53.606Z","repository":{"id":65478800,"uuid":"102971327","full_name":"andrejewski/raj-react","owner":"andrejewski","description":"React bindings for Raj","archived":false,"fork":false,"pushed_at":"2020-05-11T17:22:23.000Z","size":161,"stargazers_count":9,"open_issues_count":7,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-05T00:02:39.502Z","etag":null,"topics":["react","react-native","runtime"],"latest_commit_sha":null,"homepage":null,"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/andrejewski.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}},"created_at":"2017-09-09T17:05:38.000Z","updated_at":"2020-10-15T12:43:31.000Z","dependencies_parsed_at":"2023-01-25T08:05:16.712Z","dependency_job_id":null,"html_url":"https://github.com/andrejewski/raj-react","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andrejewski%2Fraj-react","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andrejewski%2Fraj-react/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andrejewski%2Fraj-react/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andrejewski%2Fraj-react/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/andrejewski","download_url":"https://codeload.github.com/andrejewski/raj-react/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248123740,"owners_count":21051521,"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":["react","react-native","runtime"],"created_at":"2024-11-06T21:14:13.495Z","updated_at":"2025-04-09T22:31:53.262Z","avatar_url":"https://github.com/andrejewski.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Raj React\n\u003e React bindings for [Raj](https://github.com/andrejewski/raj)\n\n```sh\nnpm install raj-react\n```\n\n[![npm](https://img.shields.io/npm/v/raj-react.svg)](https://www.npmjs.com/package/raj-react)\n[![Build Status](https://travis-ci.org/andrejewski/raj-react.svg?branch=master)](https://travis-ci.org/andrejewski/raj-react)\n[![Greenkeeper badge](https://badges.greenkeeper.io/andrejewski/raj-react.svg)](https://greenkeeper.io/)\n\n## Usage\n\n```js\nimport React from 'react'\nimport ReactDom from 'react-dom'\nimport { program } from 'raj-react'\n\nconst helloProgram = {\n  init: [{ text: 'Hello world' }],\n  update (message, state) {\n    return [state]\n  },\n  view (state, dispatch) {\n    return \u003cp\u003e{state.text}\u003c/p\u003e\n  }\n}\n\nconst App = program(React.Component, props =\u003e helloProgram)\nconst root = document.getElementById('app')\nReactDom.render(\u003cApp /\u003e, root)\n```\n\n## Documentation\n`program(Component, props =\u003e ({ init, update, view })): Component`\n- `Component`: a React Component class\n- `props`: the React component `props`\n- `init`: the initial state and optional effect\n- `update(message, state)`: return the new state and optional effect\n- `view(state, dispatch)`: return the React view\n\nThe `raj-react` package exports a single function which takes a React component class and a function which receives the component's `props` and returns a Raj program `{ init, update, view }` triplet; returns a React component.\n\n### Questions\n\n#### Where to use `raj-react`?\nThe `raj-react` package wraps the `raj` runtime and integrates within an existing React component tree. The root program is the entry point that meets the runtime. Most often, an app needs `raj-react` once. All child programs' `view` methods may return React components with no boilerplate required.\n\n#### Does this work with React Native?\nYes, `raj-react` works with both web and React Native components. In the above example, `react-dom` renders a web page component.\n\n#### Server-side rendering?\nThe `raj-react` package returns a React Component that works with [`ReactDOMServer`](https://facebook.github.io/react/docs/react-dom-server.html).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandrejewski%2Fraj-react","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fandrejewski%2Fraj-react","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandrejewski%2Fraj-react/lists"}