Collectives™ on Stack Overflow
Find centralized, trusted content and collaborate around the technologies you use most.
Learn more about Collectives
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Learn more about Teams
I changed my code from es5 class prototype representation to es6 class representation. But I am getting error
this is the code before and after migration to es6
es5 syntax
function RoutingScreen (context) {
Object.assign(this, {route} = context)
RoutingScreen.prototype.onEnter = function(state) {
state.scaning = false
state.status = 'Scan to continue'
curState = states.init
es6 syntax
class RoutingScreen{
constructor(context){
Object.assign(this, {route}= context)
onEnter(state){
state.scaning = false
state.status = 'Scan to continue'
curState = states.init
I am getting error like this
TypeError: 'set' on proxy: trap returned falsish for property 'scaning'
but es5 code is working properly.
I am using node version 8.1
I don't know what i had done wrong here.
this where i called these method
function setRoute (newRoute) {
var r = currentRoute()
console.log('changeRoute from ' + (r?r.route:'""') + ' to ' + newRoute)
if (r && r.route == newRoute) {
return true
if (!r || !r.onExit || r.onExit(state) !== false) {
stateStack.pop()
r = newRoute ? pushRoute(newRoute) : currentRoute()
state.session.route = r.route
return !r.onEnter || r.onEnter(state)
–
–
–
I was having this same issue in an example of using proxy objects I was going through the JavaScript Ninja book ... when I attempted to write a set method.
set: (target, key, value) => {
target[key] = value;
This throws a TypeError in strict mode:
Uncaught TypeError: 'set' on proxy: trap returned falsish for property
Since it was returning 'falsish', I fixed it by returning true with the method:
set: (target, key, value) => {
target[key] = value;
return true;
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.