Skip to content

Instantly share code, notes, and snippets.

View fakiolinho's full-sized avatar
🤘
Leading as usual...

Fakiolas Marios fakiolinho

🤘
Leading as usual...
View GitHub Profile
import React from 'react';
const renderItemsText = items => {
if (items.length > 0) {
return <p>Print sth since we have some items in our list</p>;
}
return null;
};
import React from 'react';
export default ({ items }) => (
<div>
{items.length > 0 ? <p>Print sth since we have some items in our list</p> : null}
</div>
);
import React from 'react';
export default ({ items }) => (
<div>
{items.length > 0 && <p>Print sth since we have some items in our list</p>}
</div>
);
import React from 'react';
export default ({ items }) => (
<div>
{!!items.length && <p>Print sth since we have some items in our list</p>}
</div>
);
import React from 'react';
export default ({ items }) => (
<div>
{Boolean(items.length) && <p>Print sth since we have some items in our list</p>}
</div>
);
import React from 'react';
export default ({ items }) => (
<div>
{items.length && <p>Print sth since we have some items in our list</p>}
</div>
);
import React from 'react';
export default ({ isTruthy }) => (
<div>
{isTruthy && <p>Print sth since prop isTruthy is really truthy</p>}
</div>
);
{
"presets": [
[
"env",
{
"targets": {
"browsers": [
"last 2 versions",
"ie > 9"
]
import React from 'react';
import { shallow } from 'enzyme';
import Options from './';
describe('test Options component', () => {
it('instance method handleAdd should be triggered when add button gets clicked', () => {
const enzymeWrapper = shallow(<Options />);
enzymeWrapper.instance().handleAdd = jest.fn();
import React, { Component } from 'react';
export default class Options extends Component {
handleAdd = () => {
console.log('add');
};
handleEdit = () => {
console.log('edit');
};