react-app-rewired-preact
Version:
Tweak the create-react-app webpack config(s) without using 'eject' and without creating a fork of the react-scripts
24 lines (20 loc) • 520 B
JavaScript
import React, { Component } from 'react';
import ReactDOM from 'react-dom';
function injectProps(target, name, descriptor) {
const oldFunction = descriptor.value;
descriptor.value = function propsInjectorFunction() {
return oldFunction.bind(this)(this.props);
};
return descriptor;
}
class App extends Component {
@injectProps
render({welcome}) {
return (
<div>
{welcome}
</div>
);
}
}
ReactDOM.render(<App welcome="hello" />, document.getElementById('root'));