{"id":15044806,"url":"https://github.com/zsytssk/react-laya","last_synced_at":"2025-10-24T14:30:40.402Z","repository":{"id":30877782,"uuid":"126260380","full_name":"zsytssk/react-laya","owner":"zsytssk","description":"use react write laya","archived":false,"fork":false,"pushed_at":"2023-01-05T10:56:04.000Z","size":2068,"stargazers_count":3,"open_issues_count":85,"forks_count":1,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-09-27T19:41:03.801Z","etag":null,"topics":["canvas","jsx","laya","react"],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","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/zsytssk.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":"2018-03-22T01:10:57.000Z","updated_at":"2023-03-20T06:15:02.000Z","dependencies_parsed_at":"2023-01-14T18:00:39.919Z","dependency_job_id":null,"html_url":"https://github.com/zsytssk/react-laya","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zsytssk%2Freact-laya","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zsytssk%2Freact-laya/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zsytssk%2Freact-laya/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zsytssk%2Freact-laya/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zsytssk","download_url":"https://codeload.github.com/zsytssk/react-laya/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":219868597,"owners_count":16555871,"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":["canvas","jsx","laya","react"],"created_at":"2024-09-24T20:51:04.218Z","updated_at":"2025-10-24T14:30:38.768Z","avatar_url":"https://github.com/zsytssk.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# install\n\n`npm install react-laya -save`\n\n# example\n\n[completecode](https://github.com/zsytssk/react-laya/tree/master/example/example1)\n\n```tsx\nimport * as React from \"react\";\nimport { render } from \"react-dom\";\nimport { Stage, Text, Image } from \"react-laya\";\n\nclass App extends React.Component\u003cany, any\u003e {\n  state = {\n    text: \"default\",\n    img: \"\",\n    rotate: 0,\n    button: \"\"\n  };\n  interval: any;\n  handleClick = () =\u003e {\n    this.setState({\n      text: \"hello world\"\n    });\n  };\n  clickImage = event =\u003e {\n    event.stopPropagation();\n    clearInterval(this.interval);\n    this.interval = setInterval(() =\u003e {\n      this.setState({\n        rotate: this.state.rotate + 10\n      });\n    }, 16);\n  };\n  text: any;\n  componentDidMount() {\n    Laya.loader.load(\n      \"res/atlas/comp.atlas\",\n      Laya.Handler.create(null, () =\u003e {\n        this.setState({\n          img: \"comp/image.png\",\n          button: \"comp/button.png\"\n        });\n      })\n    );\n  }\n  render() {\n    let state = this.state;\n    return (\n      \u003cStage ref={node =\u003e console.log(node)} onRightClick={this.handleClick}\u003e\n        \u003cText text={this.state.text} color=\"#ffffff\" /\u003e\n        \u003cTest\n          skin={this.state.img}\n          clickImage={this.clickImage}\n          rotate={this.state.rotate}\n        /\u003e\n      \u003c/Stage\u003e\n    );\n  }\n}\n\ntype TestProps = {\n  skin: string;\n  rotate?: number;\n  clickImage?: (any) =\u003e void;\n};\n\nclass Test extends React.Component\u003cTestProps, any\u003e {\n  componentDidMount() {}\n  render() {\n    return (\n      \u003cImage\n        ref={node =\u003e console.log(node)}\n        x={200}\n        y={200}\n        anchorX={0.5}\n        anchorY={0.5}\n        skin={this.props.skin}\n        rotation={this.props.rotate}\n        onClick={this.props.clickImage}\n      /\u003e\n    );\n  }\n}\n\nLaya.init(500, 300);\nvar renderelement = document.querySelector(\"#layaContainer div\");\nlet app = \u003cApp /\u003e;\nrender(app, renderelement);\n```\n\n# inspiration\n\n* [react-konva](https://github.com/lavrton/react-konva)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzsytssk%2Freact-laya","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzsytssk%2Freact-laya","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzsytssk%2Freact-laya/lists"}