Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

Super lightweight Go bindings for react.js

License

NotificationsYou must be signed in to change notification settings

rocketlaunchr/react

Repository files navigation

react

Go with ReactGoDocGo Report Card

Facebook's React is one of the most dominant libraries for front-end development around. Google's Go programming language is one of the most elegantly crafted languages for server development. Why not combine the two?

This package is an extremely thin wrapper over the native react.js API. The objective was to make it light-weight, developer-friendly and intuitive. You shouldn’t have to scour the documentation to get going — a few peeks should be adequate. If you know your way around the React API and you know a bit of Go, then you should be able to make prototypes and production-worthy applications in no time.

This package is best suited for making cross-platform Desktop applications using these technologies:

The package isproduction ready. An optional (but highly convenient)elements sub-package is also included.

SeeTutorial here.

the project to show your appreciation.

Dependencies

Installation

go get -u github.com/rocketlaunchr/react

Examples

The examples can befound here:

Uptime Timer

  • How to create React class components
  • How to pass props from parent to child
  • How to useUnmarshalProps() andUnmarshalState()
  • How to usestate() andsetState()
  • How to create strongly-typed structured props and states

Event Handling

  • How to create React functional components
  • How to handle events (and pass extra arguments)
  • How to create a Ref and interact with dom object directly
  • 100% written in Go
  • Cross-platform (macOS, Win, Linux)
  • Electron.js based
  • How to bundle javascript dependencies usingrollup.js

Performance Tips

  • Use-m command line flag to instruct gopher.js to minify code. Then bundle+minify further withrollup.js xorWebpack/UglifyJS. A Webpack tutorial can befound here.
  • Applygzip compression
  • Use int instead of (u)int8/16/32/64
  • Use float64 instead of float32
  • Avoid importingfmt at all costs (including indirectly). Usefmtless instead.
  • Avoid importingnet/http for http requests (including indirectly). Usegopherjs-xhr instead.
  • Until GopherJS supports Go1.13+, avoid using the standard librariescontext package because it usesfmt. Instead usecontext fromforks sub-package.
  • Avoid importinghonnef.co/go/js/dom if possible.
  • Usereact.JSFn() and use native javascript functions as much as possible.
  • https://github.com/gopherjs/gopherjs/wiki/JavaScript-Tips-and-Gotchas
  • See ifjsgo is appropriate for your web-based project.
  • To reduce file size, copy only what's required fromelements sub-package.
  • For json unmarshaling, tryslim-decoder or usejson

Future Work

  • WebAssembly versionHelp Required

Other useful packages

  • dataframe-go - Statistics and data manipulation
  • dbq - Zero boilerplate database operations for Go
  • electron-alert - SweetAlert2 for Electron Applications
  • igo - A Go transpiler with cool new syntax such as fordefer (defer for for-loops)
  • mysql-go - Properly cancel slow MySQL queries
  • remember-go - Cache slow database queries

Legal Information

The license is a modified MIT license. Refer toLICENSE file for more details.

© 2018-20 PJ Engineering and Business Solutions Pty. Ltd.

Final Notes

Feel free to enhance features by issuing pull-requests.


[8]ページ先頭

©2009-2025 Movatter.jp