Skip to content
This repository has been archived by the owner on Jan 16, 2023. It is now read-only.

View toggling But data Variable Is Not Modified #14

Closed
gbmhunter opened this issue Dec 5, 2015 · 12 comments
Closed

View toggling But data Variable Is Not Modified #14

gbmhunter opened this issue Dec 5, 2015 · 12 comments

Comments

@gbmhunter
Copy link

I commented out all code in the onToggle event handler (and hence the data variable does not get modified), yet the view still toggles as normal.

As far as I can understand, the view is driven from the data variable, so the view should only toggle if the corresponding toggled parameter in the data variable changes?

@alexcurtis
Copy link
Collaborator

@gbmhunter What I might do is put in a 'data-driven' boolean flag on the top level treebeard props. That can be used when you want the toggled state to be driven completely via the data prop. Then have the fallback (like it currently works using component state) -- when people don't want to handle this and just want a quick default treeview. Does that sound reasonable?

@alexcurtis
Copy link
Collaborator

Or maybe Its best to simplify it right down and make it completely data driven. Which is more react-ish. It would however, mean everyone has to define an onToggle callback to get simple things like toggling the drawer to work.

@alexcurtis
Copy link
Collaborator

@gbmhunter I have reworked treebeard to be completely data driven. I think its the best way to ensure its easy to keep extending functionality in the future. It's currently in master. Could you please try it out and see if it works well for you? Thanks!

@gbmhunter
Copy link
Author

Hi @alexcurtis ,

I have attempted to pull the latest master on GitHub with the command:

npm install git+https://github.com/alexcurtis/react-treebeard/react-treebeard.git --save

I had a look at some of the files after my attempted update, and the update seemed to have worked. However the view is still toggling while onToggle() is empty.

I also did npm rm react-treebeard --save first.

What's going on here?

@alexcurtis
Copy link
Collaborator

@gbmhunter I'm not exactly sure what happening in your project. But in the project example, if you clear out onToggle then it definitely doesn't toggle. Are you using a cached version? I would also check where it is in node_modules and that the code pulled in via require is the master branch.

@alexcurtis
Copy link
Collaborator

@gbmhunter Just thought. If you are using the master, you might need to compile down the lib before use. When I push to npm, this is automatic. But for now, whilst you test master, you will need to do this step.
Simply go into the directory and build using npm run lib. Make sure you have all the dev dependencies.

@gbmhunter
Copy link
Author

Woah, I'm running on a Windows machine and having many difficulties trying to install the dev dependencies. Many errors are being thrown when trying to run npm install -d inside the react-treebeard folder. Note that I'm not a JavaScript programmer by trade and so it probably a little behind the ball when it comes to fixing this stuff.

@gbmhunter
Copy link
Author

I am stuck in a loop with npm errors stating "Attempt to unlock , which hasn't been locked".

@alexcurtis
Copy link
Collaborator

@gbmhunter. I'll push this out to a npm release today. I'm quite happy with it being data-driven. But its a breaking change, so I'll bump up the version to 1.x.0. I'm in the middle of a decorator refactor, so once thats done, I'll push everything to a new release.

@alexcurtis
Copy link
Collaborator

@gbmhunter. I have release 1.1.0 to npm. This is a full data-driven release. No internal state. Hopefully it works as expected now.

@gbmhunter
Copy link
Author

@alexcurtis works perfectly now thank you! BTW, do you have a donate button or something similar? I'm super impressed by the effort you've put into this open-source library.

@alexcurtis
Copy link
Collaborator

@gbmhunter Thank you for your amazing support! I've added a Pledgie donate button to the Readme.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

No branches or pull requests

2 participants