Skip to content

Commit cc0ebc9

Browse files
committed
Document context, bump version
1 parent d99eb5d commit cc0ebc9

File tree

3 files changed

+35
-4
lines changed

3 files changed

+35
-4
lines changed

CHANGELOG.md

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
## 0.14.7.1
2-
* React 0.14.7 support
1+
## 0.14.1
2+
* React 0.14 support
33
* Match React version numbers
4+
* Document context
45

56
## 1.0.4
67
* Add proc/lambda/function to supported prop types for context

README.md

+31-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
[![Build Status](http://img.shields.io/travis/wied03/react-opal/master.svg?style=flat)](http://travis-ci.org/wied03/react-opal)
44

5-
**This React.rb is a a fork of the original [React.rb](https://github.com/zetachang/react.rb) [Opal Ruby](http://opalrb.org) wrapper of [React.js library](http://facebook.github.io/react/)**.
5+
**React-opal is a a fork of the original [React.rb](https://github.com/zetachang/react.rb) [Opal Ruby](http://opalrb.org) wrapper of [React.js library](http://facebook.github.io/react/)**.
66

77
## Why fork?
88
* Keep it simple, don't create an entire framework, just focus on React and Opal
@@ -28,6 +28,7 @@ React.render(React.create_element('h1'){ "Hello World!" }, `document.body`)
2828
```
2929

3030
Note: This library does not directly include a react source dependency. This allows you to specify on your own (NPM, Bower, GEMs, etc.) how you wish to use React.
31+
The version number of react-opal simply reflects which version of React that react-opal has been tested with.
3132

3233
For integration with server (Sinatra, etc), see setup of [TodoMVC](examples/todos) or the [official docs](http://opalrb.org/docs/) of Opal.
3334

@@ -145,6 +146,34 @@ def render
145146
end
146147
```
147148

149+
### Context
150+
151+
You can use the React context feature to pass values down a component hierarchy chain.
152+
153+
```ruby
154+
class ParentComponent
155+
include React::Component
156+
157+
# Simply supply the Ruby/Opal type that :foo will be and react-opal will map that to a React PropType automatically
158+
provide_context(:foo, Fixnum) { params[:foo_value] }
159+
160+
def render
161+
present ChildComponent
162+
end
163+
end
164+
165+
class ChildComponent
166+
include React::Component
167+
168+
consume_context(:foo, Fixnum)
169+
170+
def render
171+
# will render the :foo_value prop passed into ParentComponent
172+
div { "foo is #{self.context[:foo]}" }
173+
end
174+
end
175+
```
176+
148177
### Props validation
149178

150179
How about props validation? Inspired by [Grape API](https://github.com/intridea/grape), props validation rule could be created easily through `params` class method as below,
@@ -256,6 +285,7 @@ TBD
256285
## License
257286

258287
Originally Copyright (c) 2015 Yi-Cheng Chang (http://github.com/zetachang)
288+
Portions copyright (c) 2016, BSW Technology Consulting LLC
259289

260290
Permission is hereby granted, free of charge, to any person obtaining a copy
261291
of this software and associated documentation files (the "Software"), to deal

lib/react/opal/version.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
module React
2-
VERSION = '0.14.7.beta2'
2+
VERSION = '0.14.1'
33
end

0 commit comments

Comments
 (0)