react-component-assume

1.0.1 • Public • Published

react-component-assume

sometimes i want to write code like this:

var TestView;
if(someCondition){
    TestView = DialogView;
}else{
    TestView = some_NULL_Component;
}
 
//and then use this Component
<TestView name="test" cb={someFunc} />

but what a some_NULL_Component should be? it can be a blank function always return false;

var some_NULL_Component = () => false;

and i create a function warp all the things i need, namely assume.

//if condition is true, TestView is DialogView, 
//if false, TestView is a blank View that will render nothing.
var TestView = assume((condition) && DialogView);
ReactDOM.render(
    <TestView name="test" cb={someFunc} />,
    document.getElementById('root')
)

Package Sidebar

Install

npm i react-component-assume

Weekly Downloads

1

Version

1.0.1

License

MIT

Last publish

Collaborators

  • iaiae