how to use createAnimatedComponent with a styled component - react-native

whenever I use createAnimatedComponent on a styled component the way it's mentioned in here.
I get this error:
'createAnimatedComponent' does not support stateless functional components; use a class component instead.

Related

Hook functions defined by mixin not called for third-party plugin component

I'm using Vue with the Vuetify plugin.
I'm extending Vue components globally with a mixin:
Vue.mixin({
mounted() {
console.log('Component mounted');
}
});
I see the log above for all of my own components but not for the v-container component of Vuetify.
Strange thing is, when I inspect the options of this component like so:
Vue.options.components['v-container'].options.mounted
I see that the mounted function defined by my mixin is added to the array of hooks.
After creating a fiddle I was able to see it did work for all other Vuetify components.
From the docs:
Use global mixins sparsely and carefully, because it affects every
single Vue instance created, including third party components.
Am I missing something?
The problem is specific to a component in use, v-container. It is functional component and functional components cannot have lifecycle methods, so ones defined in a mixin will be ignored.
As the documentation describes functional components,
It doesn’t manage any state, watch any state passed to it, and it has no lifecycle methods. Really, it’s only a function with some props.

How i can register component globally and define default behavior?

It is possible, register component and define default behavior?
import Vue from 'vue'
import SmartSelect from '~/components/lib/smart_controls/inputs/SmartSelect'
Vue.component('smart-select', { onerror: Vue.myMethod($event), ...SmartSelect })
if you’re using Webpack (or Vue CLI 3+, which uses Webpack
internally), you can use require.context to globally register only
these very common base components
https://v2.vuejs.org/v2/guide/components-registration.html#Automatic-Global-Registration-of-Base-Components
define your default behavior inside your SmartSelect component.
if your meaning was to define a default behavior to all vue components, than you should read more about vue inheritance, which is a way to declare a base component with defaut behavior, and make other components to inherit and override that behavior. here's a good place to start

Should I be using Vue Mixins, "extends" or Vuex to share a method across all my components?

I want to have a Vue method that can be imported and used by any one of my Vue components. This method's job will be to handle exceptions passed to it (shown below).
handleException(err) {
console.error(err);
// send exception to error logging service
// do some other error-related stuff.
}
As far as I know, there are three main ways to accomplish this (please enlighten me if there are more ways that I am not aware of):
Have the method within a Vue Mixin and import this into any components that need the method.
Create a component containing the handleException method and use the "extends" keyword to import the template. (Pretty similar approach to Mixins approach).
Have the method in Vuex (as an action), which will allow me to call the method from any component using this.$store.dispatch...
For my use case, what is the best approach and why?

Is there a complete react-native Component API

At the top of my new react native app some boilerplate code is created
export default class App extends Component < {} > {
render() {
...
}
}
Within the Learn the Basics webpage of the React Native Documentation there is a section on Component. Within this section it mentions
A component can be pretty simple - the only thing that's required is a
render function...
I can't see in the API list an entry for Component. I presume this Component has the same idea as Object in Java as the base class for everything.
Java's Object class provides some methods such as toString().
I would like to know :
Is my presumption correct?
Is there a weblink to documentation somewhere that details the full
api for Component?
What else provided by react native, that isn't my own custom code, can be put inside my App
class?
You can read about React Components here. React-Native utilizes React architecture.
Component is a module of your app that has a particular functionality. On the left sidebar here you can see a section called "Components" These are the default React-Native components. You can create other components, needed in your app by using those components. Examples of how the components could look or be created are components of Expo SDK and React-Native-Elements component library.
Through this link you can view all of React-Native and Expo components on your device using Expo app: https://expo.io/#community/native-component-list
Your custom components / components of other libraries that you would like to render (put them in return statement, wrapped with parenthesis, like return (<Text>Hello World</Text>);.
Plus anything that is related to rendering your screen could also be put inside the render method, but outside the return statement. For example, state / props destructuring, conditional rendering (if something is true - show this view, else show this view) and so forth.

Aurelia: Deriving a component from another and reusing HTML

In Aurelia, how do I derive a component from another component reusing the HTML view from the source component?
I have a component BarGraph that renders simple bar graphs. This component has files bar-graph.js and bar-graph.html. I want to derive a set of components from BarGraph. Each *BarGraph class will have custom logic, but all of the derived components will have the same HTML as the original component. I want to store the HTML for the components in one file and reuse it in each *BarGraph class.
You can use #useView. For example:
import {useView} from 'aurelia-framework';
#useView('./bar-graph.html')
export class AnotherBarGraph {
// Your logic here
}
Documentation here
EDIT: Extending custom element using inheritance is currently not supported. An important point is "Inheritance of Bindables doesn't work". See this issue.