Skip to content

Instantly share code, notes, and snippets.

Andrei Pfeiffer andreipfeiffer

  • Timisoara
Block or report user

Report or block andreipfeiffer

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View jest-toContainObject.js
expect.extend({
toContainObject(received, argument) {
const pass = this.equals(received,
expect.arrayContaining([
expect.objectContaining(argument)
])
)
if (pass) {
View rn-remote-image-auto-size.js
import { Image, Dimensions } from 'react-native';
export default class RemoteImage extends Component {
constructor() {
super();
this.state = {
// this data could be static or provided by a server or api
url: 'https://...',
originalWidth: 1920,
View vue-computed.js
Vue.component('User', {
template: '<span>{{ fullName }}</span>',
props: ['firstName', 'lastName'],
computed: {
fullName() {
return this.firstName + ' ' + this.lastName;
}
}
View vue-template-logic.jsx
<template>
<div class="list-container">
<ul v-if="items.length">
<li v-for="item in items">
{{ item.name }}
</li>
</ul>
<p v-else>No items found.</p>
</div>
</template>
View vue-functional-components.js
Vue.component('Counter', {
functional: true,
render(createElement, context) {
return createElement(/**/)
}
})
View vue-animations.js
export default {
template: `
<transition name="slide">
...
</transition>
`
}
View vue-event-bus.js
// global Event Bus
const eventBus = new Vue();
/* ... */
// some deeply nested component
methods: {
onClick() {
// emit a custom event on the Event Bus, not on "this" component
eventBus.$emit('save');
View vue-components-communication.js
// parent component
template: '<Child @save="saveData" />',
methods: {
saveData() {/**/};
}
// child component
template: '<button @click="onClick">Save</button>',
methods: {
View vue-props.js
// props declaration
export default {
props: ['name', 'age']
}
// props declaration, validation & default values
export default {
props: {
name: String,
View vue-1-way-data-binding.jsx
<template>
<input :value="name" @change="update"/>
</template>
<script>
export default {
methods: {
update(event) {
this.name = event.target.value;
}
You can’t perform that action at this time.