-
Notifications
You must be signed in to change notification settings - Fork 292
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Redesigned the way we start modding components.
Now we search and grab `React.createClass` _call expressions_ directly. The only time that we can't simply replace a `createClass` call path with a new class is when the parent of that is a variable declaration: `var Foo = React.createClass({...});` needs to be replaced entirely with `class Foo extends React.Component {...}` Now we delay checking it and only when we need to replace a path we take a look at `path.parentPath.value.type` to see if it's a variable declarator. With this commit we should be able to mod any kind of anonymous `createClass` calls no matter how they are defined.
- Loading branch information
Keyan Zhang
committed
Jul 6, 2016
1 parent
1011552
commit 847de6d
Showing
5 changed files
with
222 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/** | ||
* @flow | ||
*/ | ||
/* eslint-disable no-use-before-define */ | ||
'use strict'; | ||
|
||
var React = require('React'); | ||
|
||
var CrazyObject = { | ||
foo: { | ||
bar: 123, | ||
}, | ||
method: { | ||
wrapThisGuy: (x) => x, | ||
deep: { | ||
wrapThatGuy: (x) => x, | ||
}, | ||
}, | ||
iDontUnderstand: { | ||
whyYouDoThis: { | ||
butAnyway: { | ||
comp1: React.createClass({ | ||
render() { | ||
return <div/>; | ||
}, | ||
}), | ||
comp2: CrazyObject.method.wrapThatGuy(React.createClass({ | ||
render() { | ||
return <div/>; | ||
}, | ||
})), | ||
waitWhatArrayForReal: [React.createClass({ | ||
render() { | ||
return <div/>; | ||
}, | ||
}), [React.createClass({ | ||
render() { | ||
return <p/>; | ||
}, | ||
}), React.createClass({ | ||
render() { | ||
return <span/>; | ||
}, | ||
})]], | ||
}, | ||
}, | ||
}, | ||
}; | ||
|
||
module.exports = WaltUtils; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/** | ||
* @flow | ||
*/ | ||
/* eslint-disable no-use-before-define */ | ||
'use strict'; | ||
|
||
var React = require('React'); | ||
|
||
var CrazyObject = { | ||
foo: { | ||
bar: 123, | ||
}, | ||
method: { | ||
wrapThisGuy: (x) => x, | ||
deep: { | ||
wrapThatGuy: (x) => x, | ||
}, | ||
}, | ||
iDontUnderstand: { | ||
whyYouDoThis: { | ||
butAnyway: { | ||
comp1: class extends React.Component { | ||
render() { | ||
return <div/>; | ||
} | ||
}, | ||
comp2: CrazyObject.method.wrapThatGuy(class extends React.Component { | ||
render() { | ||
return <div/>; | ||
} | ||
}), | ||
waitWhatArrayForReal: [class extends React.Component { | ||
render() { | ||
return <div/>; | ||
} | ||
}, [class extends React.Component { | ||
render() { | ||
return <p/>; | ||
} | ||
}, class extends React.Component { | ||
render() { | ||
return <span/>; | ||
} | ||
}]], | ||
}, | ||
}, | ||
}, | ||
}; | ||
|
||
module.exports = WaltUtils; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.