Skip to content

Commit 900e161

Browse files
committed
upgraded to react-0.14.0, upped to v1.0, rewrote in es6
1 parent 3de42e4 commit 900e161

17 files changed

+253
-124
lines changed

.babelrc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"stage": 0,
3+
"loose": "all"
4+
}

.eslintignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
webpack.config*.js
2+
node_modules

.eslintrc

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"extends": "eslint-config-airbnb",
3+
"env": {
4+
"browser": true,
5+
"mocha": true,
6+
"node": true
7+
},
8+
"rules": {
9+
"react/jsx-uses-react": 2,
10+
"react/jsx-uses-vars": 2,
11+
"react/react-in-jsx-scope": 2,
12+
"comma-dangle": 0, // not sure why airbnb turned this on. gross!
13+
"indent": [2, 2, {"SwitchCase": 1}],
14+
15+
//Temporarirly disabled due to a possible bug in babel-eslint (todomvc example)
16+
"block-scoped-var": 0,
17+
// Temporarily disabled for test/* until babel/babel-eslint#33 is resolved
18+
"padded-blocks": 0
19+
},
20+
"plugins": [
21+
"react"
22+
]
23+
}

.gitignore

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,6 @@
1+
.idea
12
node_modules
2-
*.iml
3+
dist
4+
lib
5+
npm-debug.log
6+
.DS_Store

.npmignore

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
src
2+
examples
3+
test
4+
.babelrc
5+
.eslint*
6+
.idea
7+
.npmignore
8+
.travis.yml
9+
webpack.*

.travis.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
language: node_js
2+
3+
node_js:
4+
- "0.12"
5+
- "4.0"
6+
- "4"
7+
8+
script:
9+
- npm run lint

AUTHORS

Lines changed: 0 additions & 1 deletion
This file was deleted.

LICENSE-MIT renamed to LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Copyright (c) 2014 Erik Rasmussen
1+
Copyright (c) 2015 Erik Rasmussen
22

33
Permission is hereby granted, free of charge, to any person
44
obtaining a copy of this software and associated documentation

NativeListener.js

Lines changed: 0 additions & 74 deletions
This file was deleted.

README.md

Lines changed: 30 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
55
## THIS IS UNRELATED TO react-native!
66

7-
Please don't confuse this library with anything to do with [React Native](https://facebook.github.io/react-native/). This library is for dealing directly with _**browser**_ native events.
7+
Please don't confuse this library with anything to do with [React Native](https://facebook.github.io/react-native/).
8+
This library is for dealing directly with _**browser**_ native events.
89

910
## Why?
1011

@@ -33,40 +34,44 @@ put your event listener properties (e.g. `onClick`, `onKeyDown`) on `<NativeList
3334

3435
So, instead of this...
3536

36-
```jsx
37-
/** @jsx React.DOM */
38-
var MyComponent = React.createClass({
39-
onButtonClick: function(event) {
37+
```javascript
38+
import React, {Component} from 'react';
39+
40+
export default class MyComponent extends Component {
41+
handleButtonClick(event) {
4042
// do something (event is React's SyntheticEvent)
41-
},
42-
render: function() {
43+
}
44+
45+
render() {
4346
return (
4447
<div>
45-
<button onClick={this.onButtonClick}>Click Me!</button>
48+
<button onClick={this.handleButtonClick.bind(this)}>Click Me!</button>
4649
</div>
4750
);
4851
}
49-
});
52+
}
5053
```
5154
...do this:
5255

53-
```jsx
54-
/** @jsx React.DOM */
55-
var NativeListener = require('react-native-listener');
56-
var MyComponent = React.createClass({
57-
onButtonClick: function(event) {
56+
```javascript
57+
import React, {Component} from 'react';
58+
import NativeListener from 'react-native-listener';
59+
60+
export default class MyComponent extends Component {
61+
handleButtonClick(event) {
5862
// do something (event is native browser event)
59-
},
60-
render: function() {
63+
}
64+
65+
render() {
6166
return (
6267
<div>
63-
<NativeListener onClick={this.onButtonClick}>
68+
<NativeListener onClick={this.handleButtonClick.bind(this)}>
6469
<button>Click Me!</button>
6570
</NativeListener>
6671
</div>
6772
);
6873
}
69-
});
74+
}
7075
```
7176

7277
**IMPORTANT:** The event passed to your function is the native browser event, _NOT
@@ -78,11 +83,12 @@ If all you want to do is stop the propagation of an event, there are convenience
7883
`stopClick`, `stopKeyDown`. For example, say you wanted to allow normal hyperlinks to work, but your
7984
component is inside some element that JQuery is calling `event.preventDefault()` for clicks...
8085

81-
```jsx
82-
/** @jsx React.DOM */
83-
var NativeListener = require('react-native-listener');
84-
var MyComponent = React.createClass({
85-
render: function() {
86+
```javascript
87+
import React, {Component} from 'react';
88+
import NativeListener from 'react-native-listener';
89+
90+
export default class MyComponent extends Component {
91+
render() {
8692
return (
8793
<div>
8894
<NativeListener stopClick>
@@ -108,4 +114,4 @@ e.g. `onClickCapture`, `onKeyDownCapture`.
108114

109115
---
110116

111-
Module submitted by [Erik Rasmussen](https://www.npmjs.org/~erikras) [@erikras](https://twitter.com/erikras)
117+
Module written by [Erik Rasmussen](https://www.npmjs.org/~erikras) [@erikras](https://twitter.com/erikras)

0 commit comments

Comments
 (0)