react-native icon indicating copy to clipboard operation
react-native copied to clipboard

[6.0] when renaming preview.js to .ts the preview config is not found

Open CezarCobuz opened this issue 4 years ago • 7 comments

Describe the bug In my package.json I have "prestart": "sb-rn-get-stories". The file storybook.requires.js gets updated with the new detected stories files but unfortunately it loses some useful content.

To Reproduce Steps to reproduce the behavior: Default setup from here with add-ons (I use controls, notes, backgrounds and actions)

Expected behavior The file storybook.requires.js keeps all the needed content and only append new stories but sb-rn-get-stories causes the file to lose this part:

import { decorators, parameters } from "./preview";

if (decorators) {
  decorators.forEach((decorator) => addDecorator(decorator));
}

if (parameters) {
  addParameters(parameters);
}

So I need to manually edit the file every single time to re-add that part.

Screenshots Screenshot 2021-11-08 at 13 33 14 .

CezarCobuz avatar Nov 08 '21 11:11 CezarCobuz

hey @CezarCobuz that code gets injected if you have a preview.js file, is there a preview.js still present in your project?

dannyhw avatar Nov 08 '21 11:11 dannyhw

It is but I renamed it to preview.ts

CezarCobuz avatar Nov 08 '21 12:11 CezarCobuz

It is but I renamed it to preview.ts

unfortunately that's whats causing the issue since it's looking specifically for preview.js

see here: https://github.com/storybookjs/react-native/blob/e2d3c5a9554fda186e80143a8642473bd7c18dc6/app/react-native/scripts/loader.js#L46-L47

However I'm happy to adjust this to better support ts extensions.

dannyhw avatar Nov 08 '21 13:11 dannyhw

Got it, thank you @dannyhw!

CezarCobuz avatar Nov 08 '21 13:11 CezarCobuz

Any progress here?

zakharchenkoAndrii avatar Jul 22 '22 09:07 zakharchenkoAndrii

@zakharchenkoAndrii not worked on it yet but the change should be relatively simple should someone wish to contribute. I'm currently away but I can take a look in a weeks time to see about adding the ts,jsx and tsx file extensions to the script.

dannyhw avatar Jul 22 '22 10:07 dannyhw

I did a PR #374, take a look please :)

zakharchenkoAndrii avatar Jul 22 '22 10:07 zakharchenkoAndrii

Merged

dannyhw avatar Mar 04 '23 13:03 dannyhw