This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
expect.extend({ | |
toContainObject(received, argument) { | |
const pass = this.equals(received, | |
expect.arrayContaining([ | |
expect.objectContaining(argument) | |
]) | |
) | |
if (pass) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Vue.component('User', { | |
template: '<span>{{ fullName }}</span>', | |
props: ['firstName', 'lastName'], | |
computed: { | |
fullName() { | |
return this.firstName + ' ' + this.lastName; | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Vue.component('Counter', { | |
functional: true, | |
render(createElement, context) { | |
return createElement(/**/) | |
} | |
}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export default { | |
template: ` | |
<transition name="slide"> | |
... | |
</transition> | |
` | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// parent component | |
template: '<Child @save="saveData" />', | |
methods: { | |
saveData() {/**/}; | |
} | |
// child component | |
template: '<button @click="onClick">Save</button>', | |
methods: { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// props declaration | |
export default { | |
props: ['name', 'age'] | |
} | |
// props declaration, validation & default values | |
export default { | |
props: { | |
name: String, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<template> | |
<input :value="name" @change="update"/> | |
</template> | |
<script> | |
export default { | |
methods: { | |
update(event) { | |
this.name = event.target.value; | |
} |
NewerOlder