{"id":19652346,"url":"https://github.com/pingf/toyreact","last_synced_at":"2025-07-10T22:41:59.771Z","repository":{"id":42719318,"uuid":"284642860","full_name":"pingf/ToyReact","owner":"pingf","description":null,"archived":false,"fork":false,"pushed_at":"2023-01-07T20:54:05.000Z","size":780,"stargazers_count":0,"open_issues_count":12,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-01-10T00:14:05.164Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pingf.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-08-03T08:16:41.000Z","updated_at":"2020-08-23T05:43:11.000Z","dependencies_parsed_at":"2023-02-08T01:35:13.278Z","dependency_job_id":null,"html_url":"https://github.com/pingf/ToyReact","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pingf%2FToyReact","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pingf%2FToyReact/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pingf%2FToyReact/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pingf%2FToyReact/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pingf","download_url":"https://codeload.github.com/pingf/ToyReact/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240960901,"owners_count":19885220,"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-11-11T15:10:23.743Z","updated_at":"2025-02-27T01:28:46.419Z","avatar_url":"https://github.com/pingf.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ToyReact\n\n\n```\nnpx webpack\n```\n\n--\u003e dist/main.js\n\n\n```\nmode: 'development',\noptimization: {\n  minimize: false\n}\n```\n\n```\nnpx webpack\n```\n\n--\u003e dist/main.js\n\n\nnpm install --save-dev babel-loader @babel/core @babel/preset-env\n\n```json\n    module: {\n        rules: [\n            {\n                test: '\\.js$',\n                use: {\n                    loader: 'babel-loader',\n                    options: {\n                        presets: ['@babel/preset-env']\n                    }\n                }\n            }\n        ]\n    },\n```\n\n\nmain.html\n```html\n\u003cscript src='main.js'\u003e\u003c/script\u003e\n```\n\nmain.js\n\n```js\nfor(let i of [1,2,3]){\n    console.log(i)\n}\n\nlet a = \u003cdiv /\u003e\n```\n\n\nnpm install --save-dev @babel/plugin-transform-react-jsx\n\n```json\n    module: {\n        rules: [\n            {\n                test: '\\.js$',\n                use: {\n                    loader: 'babel-loader',\n                    options: {\n                        presets: ['@babel/preset-env'],\n                        plugins: ['@babel/plugin-transform-react-jsx']\n                    }\n                }\n            }\n        ]\n    },\n```\n\n```\nmain.js:6 Uncaught ReferenceError: React is not defined\n    at eval (main.js:6)\n    at Object../main.js (main.js:96)\n    at __webpack_require__ (main.js:20)\n    at main.js:84\n    at main.js:87\n```\n\n```json\n    module: {\n        rules: [\n            {\n                test: '\\.js$',\n                use: {\n                    loader: 'babel-loader',\n                    options: {\n                        presets: ['@babel/preset-env'],\n                        plugins: [['@babel/plugin-transform-react-jsx', {pragma: 'createElement'}]]\n                    }\n                }\n            }\n        ]\n    },\n```\n\n```js\nfunction createElement(tagName, attributes, ...children){\n  return document.createElement(tagName);\n}\n\nlet a = \u003cdiv id=\"a\" class=\"c\"\u003e\n    \u003cdiv\u003e\u003c/div\u003e\n    \u003cdiv\u003e\u003c/div\u003e\n    \u003cdiv\u003e\u003c/div\u003e\n\u003c/div\u003e\n```\n\n```js\n\nfunction createElement(tagName, attributes, ...children){\n  let e = document.createElement(tagName);\n  for (let p in attributes){\n      e.setAttribute(p, attributes[p]);\n  }\n  for (let child of children){\n      if (typeof child === 'string') {\n          child = document.createTextNode(child);\n      }\n      e.appendChild(child);\n  }\n  return e;\n}\n\nwindow.a = \u003cdiv id=\"a\" class=\"c\"\u003e\n    \u003cdiv\u003e\u003c/div\u003e\n    \u003cdiv\u003e\u003c/div\u003e\n    \u003cdiv\u003e\u003c/div\u003e\n\u003c/div\u003e\n\n```\n\ndocument.body.appendChild(a)\n\nmain.html\n```html\n\n\u003cbody\u003e\u003c/body\u003e\n\u003cscript src='main.js'\u003e\u003c/script\u003e\n```\n\n\n```js\ndocument.body.appendChild(\u003cMyComponent id=\"a\" class=\"c\"\u003e\n    \u003cdiv\u003e1\u003c/div\u003e\n    \u003cdiv\u003e2\u003c/div\u003e\n    \u003cdiv\u003e3\u003c/div\u003e\n\u003c/MyComponent\u003e)\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpingf%2Ftoyreact","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpingf%2Ftoyreact","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpingf%2Ftoyreact/lists"}