Can you integrate the new Composition API into a traditional component that uses the Options API?
Here's my situation:
// ComponentA.js
import { reactive } from '@vue/composition-api'
export default {
////////////////////////////////////////////////////////////////
setup() {
//////////////////////////////////////////////
// State
const state = reactive({
isSearching: false,
searchText: '',
isShowMoreResults: false,
resultItems: []
})
//////////////////////////////////////////////
const search = async (searchText) => {
console.log("Searching... ", searchText)
}
//////////////////////////////////////////////
const clear = async () => {
console.log("Clear search")
}
//////////////////////////////////////////////
const nextResults = async () => {
console.log("Next Results")
}
////////////////////////////////////////////////////////////////
return {
state,
search,
clear,
nextResults
}
}
}
I'm trying to use it in a component using the "Options API" style. How can I go about importing this?
I attempted this approach, but encountered issues.
import useComponentA from 'ComponentA.js'
let { state } = useComponentA()