Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cannot log action info #2324

Closed
WillCoco opened this issue Nov 16, 2017 · 13 comments
Closed

cannot log action info #2324

WillCoco opened this issue Nov 16, 2017 · 13 comments
Assignees
Labels

Comments

@WillCoco
Copy link

storybook: v3.2.16
react-native: v0.45.1

error info: Attempting to change value of a readonly property
caused by this line: Object.defineProperty(handler, { value: {'name': fnName }});

@Hypnosphi Hypnosphi self-assigned this Nov 16, 2017
@Hypnosphi Hypnosphi added the bug label Nov 16, 2017
@Hypnosphi
Copy link
Member

Seems to work OK with react-native@0.49.3 (examples/crna-kitchen-sink)

@danielduan what can I do to degrade the app to RN 0.45 locally so that I could reproduce this?

@danielduan
Copy link
Member

danielduan commented Nov 16, 2017

In the CRNA example, change the App.json expo version. Downgrade the react, react-native, and expo dependencies. @Hypnosphi

They need to match:
https://github.com/react-community/create-react-native-app/blob/master/VERSIONS.md

@Hypnosphi
Copy link
Member

And replace index.js with index.android.js, right?

@danielduan
Copy link
Member

Oh yeah! It might not matter though because its set up to look for the version default.

@shilman
Copy link
Member

shilman commented Nov 16, 2017

I'm unable to reproduce on first attempt. Here's what I did:

First, edit examples/react-native-vanilla/package.json:

    "react": "16.0.0-alpha.12",
    "react-native": "0.45.1"

Then:

yarn bootstrap --reactnative
cd examples/react-native-vanilla
yarn storybook
yarn react-native run-ios

Clicking on the button logs to the actions panel successfully? Let me know if I'm doing something wrong.

@Tarabyte
Copy link
Contributor

Tarabyte commented Nov 18, 2017

Same here

 "@storybook/react-native": "^3.2.16",
 "@storybook/addon-actions": "^3.2.16",
 "react": "16.0.0",
 "react-native": "^0.49.3",
 "expo": "^22.0.0",

when running on android emulator.

Though works ok when trying to debug in Chrome.

@Tarabyte
Copy link
Contributor

@Hypnosphi You might want to check

if (Object.getOwnPropertyDescriptor(handler, 'name').configurable) 

in current engine here https://github.com/storybooks/storybook/blob/5cd3dde2ba3ec12a94a9439c1d3a5822dd01ccd4/addons/actions/src/preview.js#L28

And fallback to eval version. Or atleast wrap this line with try-catch as a quickfix 😄

@Hypnosphi
Copy link
Member

I’d prefer to figure out first, why it becomes non-configurable

@Tarabyte
Copy link
Contributor

I'd say this is js engine implementation bug. function.name indeed is not configurable on android.
Check the note here https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/name saying it was configurable: false before ES2015.

@hushicai
Copy link

I meet the same issue too.

but when i Debug on Remotely, everything is ok.

react-native: 0.47.2
react-native-storybook:3.2.16

@Hypnosphi
Copy link
Member

Hypnosphi commented Nov 18, 2017

@Tarabyte Oh I see. I‘d prefer to keep the name as is rather than use the eval hack in those cases. Would you like to submit a PR?

@Hypnosphi
Copy link
Member

Hypnosphi commented Nov 18, 2017

We could also try to make handler truly anonymous before assigning the dynamic name:

  const handler = (() => (..._args) => {
    const args = Array.from(_args).map(_format);
    const channel = addons.getChannel();
    const id = uuid();
    channel.emit(EVENT_ID, {
      id,
      data: { name, args },
    });
  })();

@danielduan
Copy link
Member

Published in 3.2.17

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants