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 work in notebook v6 #429

Open
fecet opened this issue Dec 20, 2023 · 1 comment
Open

cannot work in notebook v6 #429

fecet opened this issue Dec 20, 2023 · 1 comment
Assignees

Comments

@fecet
Copy link

fecet commented Dec 20, 2023

I can not run the following example code in notebook 6.5.4

import solara

# Declare reactive variables at the top level. Components using these variables
# will be re-executed when their values change.
sentence = solara.reactive("Solara makes our team more productive.")
word_limit = solara.reactive(10)


@solara.component
def Page():
    # Calculate word_count within the component to ensure re-execution when reactive variables change.
    word_count = len(sentence.value.split())

    solara.SliderInt("Word limit", value=word_limit, min=2, max=20)
    solara.InputText(label="Your sentence", value=sentence, continuous_update=True)

    # Display messages based on the current word count and word limit.
    if word_count >= int(word_limit.value):
        solara.Error(f"With {word_count} words, you passed the word limit of {word_limit.value}.")
    elif word_count >= int(0.8 * word_limit.value):
        solara.Warning(f"With {word_count} words, you are close to the word limit of {word_limit.value}.")
    else:
        solara.Success("Great short writing!")


# The following line is required only when running the code in a Jupyter notebook:
Page()

image

Does this only work for jupyter lab? (notebook v7 is jupyter lab also)

@iisakkirotko iisakkirotko self-assigned this Jan 2, 2024
@iisakkirotko
Copy link
Collaborator

iisakkirotko commented Jan 2, 2024

Hi @fecet!

Have you tried clearing cache and refreshing? If this does not fix the issue, could you take a look at the browser console and sharing the error(s) displayed there?

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