Skip to content

react-stoon is a handy toolbox of reusable Components that allow you to reduce boilerplate by writing less js inside of your React Components.

License

Notifications You must be signed in to change notification settings

AzarouAmine/react-stoon

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

react-stoon

npm version license dependency status Join the chat at https://gitter.im/MoroccanOSS/react-stoon

react-stoon is a handy toolbox of reusable Components that allow you to reduce boilerplate by writing less js inside of your React Components.

react-stoon is a fast growing toolbox aspiring to be your lodash for React.

Show

renders $ only if if is truthy.

const MyComponent = ({ shouldShowText }) => {
    return (
        <Show
        $={Text}
        if={shouldShowText}
        >
            You can see this text, only if props.if is true
        </Show>
    );
}

Repeat

creates times copies of $.

const MyComponent = () => {
    return (
        <Repeat
        $={Text}
        times={5}
        >
            This Text will be repeated 5 times
        </Repeat>
    );
}

Switch

renders Switch.Case if value matches target.

const MyComponent = () => {
    return (
        <Switch
        $={Div}
        target='Hello'
        >
            <Switch.Case
            $={Text}
            value='Hey'
            >
                the target equals Hey
            </Switch.Case>
            <Switch.Case
            $={Text}
            value='Hello'
            >
                the target equals Hello
            </Switch.Case>
        </Switch>
    );
}

LifeCycleAware

allows you to use React's lifecycle Hooks without turning your component to a class.

const MyComponent = () => {
    return (
        <LifeCycleAware
        $={Text}
        willMount={() => console.log('Will Mount!')}
        didMount={() => console.log('Did Mount!')}
        >
            Hello, I am a LifecycleAwareComponent!
        </LifeCycleAware>
    );
}

About

react-stoon is a handy toolbox of reusable Components that allow you to reduce boilerplate by writing less js inside of your React Components.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%