motion
Version:
motion - moving development forward
28 lines (22 loc) • 775 B
JavaScript
import React from 'react'
import reportError from '../lib/reportError'
// convert object to string for debugging
export default function(el, args, view) {
return args.map(arg => {
const type = typeof arg
if (arg && type != 'string' && !Array.isArray(arg) && !React.isValidElement(arg)) {
const isObj = String(arg) === '[object Object]'
if (isObj) {
// stringify for error
let str = ''
try { str = JSON.stringify(arg) } catch(e) {}
reportError({
message: `You passed an object to ${view.name} <${el.name}>. In production this will error! Object: ${str}`,
fileName: _Motion.views[view.name] && _Motion.views[view.name].file
})
return str || '{}'
}
}
return arg
})
}