一个在 React 中使用 gRPC-Web 和 Go 后端实现 Hacker News 阅读器的示例应用
An example app implementing a Hacker News reader. This example aims to demonstrate usage of grpc-web(v0.5.0) with React. It additionally shows how to integrate with Redux.
To start both the Go backend server and the frontend React application, run the following:
./start.shThe backend server is running on http://localhost:8900 while the frontend will by default start on http://localhost:3000
Contributions are welcome, please open an Issue or raise a PR.
Gernerated proto classes do not confirm to TS lint requirements, disable linting
{
"linterOptions": {
"exclude": [
"src/proto/*"
]
},
}In this example, we're using a protoc.sh script to aid compilation
protoc \
--go_out=plugins=grpc:./server \
--plugin=protoc-gen-ts=./app/node_modules/.bin/protoc-gen-ts \
--ts_out=service=true:./app/src \
--js_out=import_style=commonjs,binary:./app/src \
./proto/hackernews.protoRedux favors plain objects over object instances. This complicates usage of the generated proto classes, in this example class Story. In order to use the generated classes with redux, we must use the Story.AsObject type which is the plain object representation. For example our reducer should look like this:
…Note the usage of Story.AsObject rather than just Story
An example redux middleware is included.
…暂无开放 Issues,或尚未同步最近议题。