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

Updating board data does not re-render the board? #19

Closed
sluongng opened this issue Sep 5, 2017 · 5 comments
Closed

Updating board data does not re-render the board? #19

sluongng opened this issue Sep 5, 2017 · 5 comments

Comments

@sluongng
Copy link

sluongng commented Sep 5, 2017

Hi, I am currently having board data as a prop boardData: {lanes: []} in constructor() and then I try to fetch the lanes in componentDidMount(). My problem is that even after fetching successfully and this.state.boardData were updated, the board is still rendering with {lanes: []}

Is it not possible to render the board dynamically right now?

@rcdexta
Copy link
Owner

rcdexta commented Sep 5, 2017

You have to pass the board data as data prop. Check out this example repo as a reference to use this library: https://github.com/rcdexta/react-trello-example

@sluongng
Copy link
Author

sluongng commented Sep 5, 2017

I used that exact example to start out @rcdexta
But I noticed that you are using json file instead of fetching json data from another webservice so I am trying that

image

so I have

constructor(props) {
        super(props);

        this.state = {
            isLoading: false,
            boardData: {
                lanes: []
            }
        }
    }

boardData here will be modified by

async componentWillMount() {
        this.setState({isLoading: true});

        try {
            const reponse = await this.getBoard();

            console.log("DEBUG This is premount results: " + reponse);

            this.setState({ boardData: reponse });
        }
        catch (e) { alert(e); }

        console.log("DEBUG This is list after mount: " + this.state.boardData);

        this.setState({isLoading: false});
    }

    getBoard() {
        const response = invokeBackend({path: '/testservice/cards', method: 'GET'});

        return response;
    }

What I dont understand here is for the life of me the board is empty after state is newly set by this.setState({ boardData: reponse });

rcdexta added a commit that referenced this issue Sep 6, 2017
…ccepting new changes to state v

The same prop 'data' was used to share the current state of the board between the input prop data
and the state maintained by the store/reducer. Now, due to namespace overlap, any new changes to
data prop effected from outside Board component is not affected internally

#19
@rcdexta
Copy link
Owner

rcdexta commented Sep 6, 2017

I created a story to simulate this scenario and actually found a glitch in state management that was causing this issue. Thanks for bringing this up!

The new behaviour that you are expecting is documented here: https://github.com/rcdexta/react-trello/blob/master/stories/AsyncLoad.story.js

Pls try the latest build and revert back if it works for you...

@sluongng
Copy link
Author

sluongng commented Sep 6, 2017

Yup I digged up the code and found whats wrong and fixed it with another loading-state alternating the render process. Not entirely sure why directly updating data didnt work but current workaround gave me better idea for implementation my board.

Closing.

@sluongng sluongng closed this as completed Sep 6, 2017
@mohaimenmahi
Copy link

Is there any way of updating the board data into DB like MongoDB or other NoSQL? I mean when I will dnd a card from one lane to another, I have to update the whole card in the state as well as in DB.

reactexp925 added a commit to reactexp925/react-trello that referenced this issue Dec 5, 2019
…ccepting new changes to state v

The same prop 'data' was used to share the current state of the board between the input prop data
and the state maintained by the store/reducer. Now, due to namespace overlap, any new changes to
data prop effected from outside Board component is not affected internally

rcdexta/react-trello#19
pikachunerdy added a commit to pikachunerdy/react-trello that referenced this issue Oct 7, 2022
…ccepting new changes to state v

The same prop 'data' was used to share the current state of the board between the input prop data
and the state maintained by the store/reducer. Now, due to namespace overlap, any new changes to
data prop effected from outside Board component is not affected internally

rcdexta/react-trello#19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants