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

How to rename file when adding new file. #71

Open
damquanghieu opened this issue Aug 12, 2022 · 8 comments
Open

How to rename file when adding new file. #71

damquanghieu opened this issue Aug 12, 2022 · 8 comments
Labels
enhancement New feature or request

Comments

@damquanghieu
Copy link

I want to change the default name when creating a new file. For example "new page" I want to use for new functionality. Thanks very much

@shunjizhan
Copy link
Owner

shunjizhan commented Aug 12, 2022

ooooops seems we don't have a way to do that, sorry about it, but seems like a great FR for the next version

@shunjizhan shunjizhan added the enhancement New feature or request label Aug 12, 2022
@damquanghieu
Copy link
Author

ooooops seems we don't have a way to do that, sorry about it, but seems like a great FR for the next version

Is there any way I can do it for example overriding something?

@shunjizhan
Copy link
Owner

one hack way is to fork and change this line https://github.com/shunjizhan/react-folder-tree/blob/master/src/components/EditableName/EditableName.jsx#L56
so that when it sees the default name, it display what you need

@shunjizhan
Copy link
Owner

something like

{ name === DEFAULT_NAME ? 'new page' : name }

@damquanghieu
Copy link
Author

something like

{ name === DEFAULT_NAME ? 'new page' : name }

Thanks so much.

@damquanghieu
Copy link
Author

image
This feature.
I have a problem trying to set setTreeState from a data from the api in useEffect(),
But my application was looping infinitely. Can you tell me the best way to set initState from the result of an api and not a sample data like testData?

image
My code will look like this

@ErnestoLopez
Copy link

hello,

The same thing happens to me, if I update the data property with a state like you do, specifically when I add a folder, it gets into an infinite loop because every time I update as you do with "setTreeState" it re-identifies the event " addNode" and repeat the cycle.

Did you know how to fix it?

Thank you.

Ernesto

@ErnestoLopez
Copy link

I fixed it using a new state

`
const handle_FolderTree_onTreeStateChange = async (state: object, event: any) => {

    if (stateHandlingEvent == true) {
        setStateHandlingEvent(false);
        }
    else {
        setStateHandlingEvent(true);
        const result = await FolderTree_onTreeStateChange(state, event);
        }
    }

`

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

No branches or pull requests

3 participants