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

Story Props Documentation Are Potentially Misleading #61

Open
kpapa05 opened this issue Oct 19, 2024 · 1 comment
Open

Story Props Documentation Are Potentially Misleading #61

kpapa05 opened this issue Oct 19, 2024 · 1 comment
Labels
documentation Improvements or additions to documentation

Comments

@kpapa05
Copy link

kpapa05 commented Oct 19, 2024

According to the documentation:

image

This would lead someone to believe they could do something like this:

const controls = {
  Color: Color3.fromRGB(0, 0, 255),
  Text: "Hello World!",
};

const story = {
  react: React,
  reactRoblox: ReactRoblox,
  controls: controls,
  story: (props: InferProps<typeof controls>) => {
    const component = (
      <frame
        AnchorPoint={new Vector2(0.5, 0.5)}
        BackgroundTransparency={1}
        Position={UDim2.fromScale(0.5, 0.5)}
        Size={UDim2.fromScale(0.5, 0.5)}
      >
        <Button Color={props.Color} Text={props.Text} />
      </frame>
    );
    return component;
  },
};

When in fact, they need to do this:

const controls = {
  Color: Color3.fromRGB(0, 0, 255),
  Text: "Hello World!",
};

const story = {
  react: React,
  reactRoblox: ReactRoblox,
  controls: controls,
  story: (props: { controls: InferProps<typeof controls> }) => {
    const component = (
      <frame
        AnchorPoint={new Vector2(0.5, 0.5)}
        BackgroundTransparency={1}
        Position={UDim2.fromScale(0.5, 0.5)}
        Size={UDim2.fromScale(0.5, 0.5)}
      >
        <Button Color={props.controls.Color} Text={props.controls.Text} />
      </frame>
    );
    return component;
  },
};

When encountering this, I personally found my way searching around the OSS server before stumbling on a completely unrelated answer which happened to have the solution. If we add some more clarity to the documentation, it would be beneficial.

@PepeElToro41
Copy link
Owner

yeah maybe it can be specified that the controls are inside props.controls.

However, if Im not missing something, InferProps infers the props argument, InferControls would infer the controls value, which is what you are trying to do there.

in any case, because the props are typed, typescript should autocomplete the keys inside, which you'd see that it has a controls key

@PepeElToro41 PepeElToro41 added the documentation Improvements or additions to documentation label Oct 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

2 participants