A collection of helpers for conditionally rendering components or elements in React.
import h from 'react-hyperscript';
import { hideIf } from 'react-render-helpers';
import hideIf from 'react-render-helpers/hideIf'
export default ({ isClosed }) => h('.window', {}, [
hideIf(isClosed)(h('div', {}, 'Window is open!')),
hideIf(isClosed)(() => h('div', {}, 'Window is open!')),
]);
import h from 'react-hyperscript';
import { showIf } from 'react-render-helpers';
import showIf from 'react-render-helpers/showIf'
export default ({ isClosed }) => h('.window', {}, [
showIf(isClosed)(h('div', {}, 'Window is closed!')),
showIf(isClosed)(() => h('div', {}, 'Window is closed!')),
]);
import h from 'react-hyperscript';
import { switchOn } from 'react-render-helpers';
import switchOn from 'react-render-helpers/switchOn'
export default ({ color }) => h('.palette', {}, [
switchOn(color)({
blue: h('div.blue', { style: { color: 'blue' } }, 'Blue!'),
red: h('div.red', { style: { color: 'red' } }, 'Red!'),
defaultTo: h('div', {}, 'No color...'),
}),
switchOn(color)({
blue: () => h('div.blue', { style: { color: 'blue' } }, 'Blue!'),
red: () => h('.red', { style: { color: 'red' } }, 'Red!'),
defaultTo: () => h('div', {}, 'No color...') ,
}),
]);