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

server-side functions are sometimes undefined #117

Open
GDOR-11 opened this issue Nov 21, 2024 · 0 comments
Open

server-side functions are sometimes undefined #117

GDOR-11 opened this issue Nov 21, 2024 · 0 comments

Comments

@GDOR-11
Copy link

GDOR-11 commented Nov 21, 2024

for some reason, the following snippets of code sometimes log [Function: foo] (as expected) and sometimes log undefined

// file: ./server/main.ts

export function foo(): string {
    return "bar";
}
// file: ./src/main.tsx

import { Devvit } from "@devvit/public-api";
import { foo } from "../server/main.js";

Devvit.configure({
    redditAPI: true,
});

Devvit.addMenuItem({
    label: "Create minigames post",
    location: "subreddit",
    forUserType: "moderator",
    onPress: async (_event, { reddit, ui }) => {
        await reddit.submitPost({
            title: "title",
            subredditName: (await reddit.getCurrentSubreddit()).name,
            preview: (
                <vstack height="100%" width="100%" alignment="middle center">
                    <text size="large">Loading...</text>
                </vstack>
            ),
        });
        ui.showToast({ text: "Created post!" });
    },
});

Devvit.addCustomPostType({
    name: "Experience Post",
    render: _context => {
        console.log(foo); // sometimes logs [Function: foo] and sometimes logs undefined
        return <text>lorem ipsum dolor sit amet</text>;
    },
});

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

No branches or pull requests

1 participant